Skip to content

Instantly share code, notes, and snippets.

@andferrari
Created November 15, 2021 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andferrari/f3bbf71c3696bb797e8e532e24556b8b to your computer and use it in GitHub Desktop.
Save andferrari/f3bbf71c3696bb797e8e532e24556b8b to your computer and use it in GitHub Desktop.
sort GPUs
function sort_gpus()
mems = Int[]
gpus = collect(CUDA.devices())
for k in 1:length(gpus)
CUDA.device!(k-1)
push!(mems, CUDA.available_memory())
end
ind = sortperm(mems, rev=true)
hcat(gpus[ind], mems[ind])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment