Skip to content

Instantly share code, notes, and snippets.

@ShannonScott
Last active June 4, 2023 20:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShannonScott/0c528f18f68955746893759e2cca1366 to your computer and use it in GitHub Desktop.
Save ShannonScott/0c528f18f68955746893759e2cca1366 to your computer and use it in GitHub Desktop.
[List NVDIA GPUs] Bash array of GPUs in a system. #tags: nvidia, gpu, bash
#!/bin/bash
# Get a list of GPUs in a system
#
# Useful nvidia-smi Queries
# https://nvidia.custhelp.com/app/answers/detail/a_id/3751/~/useful-nvidia-smi-queries
# Get GPU names as a bach array, replace spaces with underscores
gpu_names=($(nvidia-smi --query-gpu=gpu_name --format=csv,noheader | tr -s ' ' '_'))
for name in "${gpu_names[@]}"
do
echo $name
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment