Created
September 20, 2017 00:13
-
-
Save rkaplan/32c3489c0009fa13f479567d879df0a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generates aliases for .bashrc that allow easy toggling of CUDA_VISIBLE_DEVICES | |
# The printf is to name the tmux pane with which GPUs are available | |
ALIAS_STR = 'alias {name}=\'printf "\\033]2;%s\\033\\\\" "GPU: {gpu_list}"; export CUDA_VISIBLE_DEVICES="{gpu_list}"\'' | |
ngpu = 8 | |
for i in range(ngpu): | |
print(ALIAS_STR.format(name="g" + str(i), gpu_list=str(i))) | |
for i in range(ngpu-1): | |
for j in range(i+1, ngpu): | |
gpu_list = ','.join(map(str, list(range(i, j + 1)))) | |
name = 'g{}{}'.format(i, j) | |
print(ALIAS_STR.format(name=name, gpu_list=gpu_list)) | |
# output: | |
# alias g0='printf "\033]2;%s\033\\" "GPU: 0"; export CUDA_VISIBLE_DEVICES="0"' | |
# alias g1='printf "\033]2;%s\033\\" "GPU: 1"; export CUDA_VISIBLE_DEVICES="1"' | |
# alias g2='printf "\033]2;%s\033\\" "GPU: 2"; export CUDA_VISIBLE_DEVICES="2"' | |
# alias g3='printf "\033]2;%s\033\\" "GPU: 3"; export CUDA_VISIBLE_DEVICES="3"' | |
# alias g4='printf "\033]2;%s\033\\" "GPU: 4"; export CUDA_VISIBLE_DEVICES="4"' | |
# alias g5='printf "\033]2;%s\033\\" "GPU: 5"; export CUDA_VISIBLE_DEVICES="5"' | |
# alias g6='printf "\033]2;%s\033\\" "GPU: 6"; export CUDA_VISIBLE_DEVICES="6"' | |
# alias g7='printf "\033]2;%s\033\\" "GPU: 7"; export CUDA_VISIBLE_DEVICES="7"' | |
# alias g01='printf "\033]2;%s\033\\" "GPU: 0,1"; export CUDA_VISIBLE_DEVICES="0,1"' | |
# alias g02='printf "\033]2;%s\033\\" "GPU: 0,1,2"; export CUDA_VISIBLE_DEVICES="0,1,2"' | |
# alias g03='printf "\033]2;%s\033\\" "GPU: 0,1,2,3"; export CUDA_VISIBLE_DEVICES="0,1,2,3"' | |
# alias g04='printf "\033]2;%s\033\\" "GPU: 0,1,2,3,4"; export CUDA_VISIBLE_DEVICES="0,1,2,3,4"' | |
# alias g05='printf "\033]2;%s\033\\" "GPU: 0,1,2,3,4,5"; export CUDA_VISIBLE_DEVICES="0,1,2,3,4,5"' | |
# alias g06='printf "\033]2;%s\033\\" "GPU: 0,1,2,3,4,5,6"; export CUDA_VISIBLE_DEVICES="0,1,2,3,4,5,6"' | |
# alias g07='printf "\033]2;%s\033\\" "GPU: 0,1,2,3,4,5,6,7"; export CUDA_VISIBLE_DEVICES="0,1,2,3,4,5,6,7"' | |
# alias g12='printf "\033]2;%s\033\\" "GPU: 1,2"; export CUDA_VISIBLE_DEVICES="1,2"' | |
# alias g13='printf "\033]2;%s\033\\" "GPU: 1,2,3"; export CUDA_VISIBLE_DEVICES="1,2,3"' | |
# alias g14='printf "\033]2;%s\033\\" "GPU: 1,2,3,4"; export CUDA_VISIBLE_DEVICES="1,2,3,4"' | |
# alias g15='printf "\033]2;%s\033\\" "GPU: 1,2,3,4,5"; export CUDA_VISIBLE_DEVICES="1,2,3,4,5"' | |
# alias g16='printf "\033]2;%s\033\\" "GPU: 1,2,3,4,5,6"; export CUDA_VISIBLE_DEVICES="1,2,3,4,5,6"' | |
# alias g17='printf "\033]2;%s\033\\" "GPU: 1,2,3,4,5,6,7"; export CUDA_VISIBLE_DEVICES="1,2,3,4,5,6,7"' | |
# alias g23='printf "\033]2;%s\033\\" "GPU: 2,3"; export CUDA_VISIBLE_DEVICES="2,3"' | |
# alias g24='printf "\033]2;%s\033\\" "GPU: 2,3,4"; export CUDA_VISIBLE_DEVICES="2,3,4"' | |
# alias g25='printf "\033]2;%s\033\\" "GPU: 2,3,4,5"; export CUDA_VISIBLE_DEVICES="2,3,4,5"' | |
# alias g26='printf "\033]2;%s\033\\" "GPU: 2,3,4,5,6"; export CUDA_VISIBLE_DEVICES="2,3,4,5,6"' | |
# alias g27='printf "\033]2;%s\033\\" "GPU: 2,3,4,5,6,7"; export CUDA_VISIBLE_DEVICES="2,3,4,5,6,7"' | |
# alias g34='printf "\033]2;%s\033\\" "GPU: 3,4"; export CUDA_VISIBLE_DEVICES="3,4"' | |
# alias g35='printf "\033]2;%s\033\\" "GPU: 3,4,5"; export CUDA_VISIBLE_DEVICES="3,4,5"' | |
# alias g36='printf "\033]2;%s\033\\" "GPU: 3,4,5,6"; export CUDA_VISIBLE_DEVICES="3,4,5,6"' | |
# alias g37='printf "\033]2;%s\033\\" "GPU: 3,4,5,6,7"; export CUDA_VISIBLE_DEVICES="3,4,5,6,7"' | |
# alias g45='printf "\033]2;%s\033\\" "GPU: 4,5"; export CUDA_VISIBLE_DEVICES="4,5"' | |
# alias g46='printf "\033]2;%s\033\\" "GPU: 4,5,6"; export CUDA_VISIBLE_DEVICES="4,5,6"' | |
# alias g47='printf "\033]2;%s\033\\" "GPU: 4,5,6,7"; export CUDA_VISIBLE_DEVICES="4,5,6,7"' | |
# alias g56='printf "\033]2;%s\033\\" "GPU: 5,6"; export CUDA_VISIBLE_DEVICES="5,6"' | |
# alias g57='printf "\033]2;%s\033\\" "GPU: 5,6,7"; export CUDA_VISIBLE_DEVICES="5,6,7"' | |
# alias g67='printf "\033]2;%s\033\\" "GPU: 6,7"; export CUDA_VISIBLE_DEVICES="6,7"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment