-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgpu_utils.sh
More file actions
46 lines (38 loc) · 858 Bytes
/
Copy pathgpu_utils.sh
File metadata and controls
46 lines (38 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
# copy this into your ~/.bashrc
# CUDA stuff
export CUDA_HOME=/usr/local/cuda
export PATH=$PATH:$CUDA_HOME/bin
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$CUDA_HOME/lib
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$CUDA_HOME/lib
#GPU Usage Tools
gpustat() {
watch --color -n 1 "python ~/gpustat.py -u -c 2> /dev/null"
}
set-visible-gpus() {
GPU_ID=""
for i in "$@"
do
GPU_ID="$GPU_ID $i"
done
export CUDA_VISIBLE_DEVICES=$GPU_ID
}
reset-visible-gpus() {
unset CUDA_VISIBLE_DEVICES
}
get-total-gpus() {
GPUS_LEN=$(($(nvidia-smi -L | wc -l) - 1))
GPUS=""
for i in $(seq 0 $GPUS_LEN);
do
GPUS="$GPUS ${i}"
done
echo $GPUS
}
get-visible-gpus() {
if [ -n "$CUDA_VISIBLE_DEVICES" ];
then
echo $CUDA_VISIBLE_DEVICES;
else
get-total-gpus;
fi