Skip to content
Snippets Groups Projects
Commit 2c7eceac authored by patmjen's avatar patmjen
Browse files

Change init script to select least used GPU

parent 62ffb7a5
No related branches found
No related tags found
No related merge requests found
...@@ -30,10 +30,10 @@ then ...@@ -30,10 +30,10 @@ then
fi fi
source ${VENV_DIR}/${VENV_NAME}/bin/activate source ${VENV_DIR}/${VENV_NAME}/bin/activate
# Make all GPUs visible # Select least used GPU if any are available
if command -v nvidia-smi &> /dev/null if command -v nvidia-smi &> /dev/null
then then
export CUDA_VISIBLE_DEVICES=$(nvidia-smi --query-gpu=index --format=csv,noheader | tr '\n' ',') export CUDA_VISIBLE_DEVICES=$(nvidia-smi --query-gpu=memory.used,utilization.gpu,utilization.gpu,index --format=csv,noheader,nounits | sort -V | awk '{print $NF}' | head -n1)
echo CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES} echo CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES}
fi fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment