So I do research in machine learning and use a remote GPU server to do the stuff. What I usually do when I come to work is access the server with an SSH client and run my alias hi
command which is:
alias hi='conda activate userconda; export CUDA_VISIBLE_DEVICES=1; alias hi'
The server is usually shared among two to three people and has two GPU's, each with ID 0
or 1
.
What I'm wondering is, would there be some kind of way to automatically determine which GPU ID to assign to the environment variable CUDA_VISIBLE_DEVICES
based on which GPU isn't being used? Right now my alias is hard coded to be CUDA_VISIBLE_DEVICES=1
, but it would be more convenient if the program could do that automatically.
I was thinking maybe there could be a way to use the output of nvidia-smi
, but I'm not sure if that would be the right approach.
Thanks!