Created
October 4, 2017 13:35
-
-
Save selwynsimsek/b38c60a9b5782ba34f628f600bc4fbc2 to your computer and use it in GitHub Desktop.
Sets CUDA_VISIBLE_DEVICES to be the ID of the GPU with the most free memory.
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
#!/bin/bash | |
# Sets CUDA_VISIBLE_DEVICES to be the ID of the GPU with the most free memory, via text munging of nvidia-smi output. | |
# | |
# Usage: set-cvd.sh ./cudaexec sets CUDA_VISIBLE_DEVICES and runs cudaexec. | |
# | |
# | |
export CUDA_VISIBLE_DEVICES=$(nvidia-smi | grep % | awk '{print $9 }' | tr -d MiB | nl | sort -k2 -n | head -1 | awk '{print $1 -1}') | |
$* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment