This file contains 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 | |
# Written by uaudith[uaudith.eu.org] | |
# Use the environment variable $CUDA_VISIBLE_DEVICES inside your program to get comma separated list of free devices | |
command_to_run="$@" | |
utilization_threshold=0 #Will run the command if the device utilization percentage is less than this | |
get_free_gpus() { | |
mapfile -t util_array < <(nvidia-smi --query-gpu=utilization.gpu --format=csv,nounits,noheader) |