Skip to content

Commit e8d3e46

Browse files
Update gpu_name.sh
1 parent 7010e59 commit e8d3e46

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scripts/gpu_name.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ print_gpu_name() {
1515
echo "No GPU"
1616
return
1717
fi
18-
gpu_name=$(echo "$loads" | nvidia-smi | grep -Eo "NVIDIA\s+\w+\s+\w+\s[0-9]+")
19-
gpu_nums=$(nvidia-smi --query-gpu=count --format=csv,noheader)
20-
if [ ${gpu_nums} -eq 1 ]; then
21-
echo ${gpu_name}
18+
gpu_name=$(nvidia-smi --query-gpu=gpu_name --format=csv,noheader | sort | uniq)
19+
gpu_nums=$(nvidia-smi --query-gpu=count --format=csv,noheader | sort | uniq)
20+
if [ "${gpu_nums}" -eq 1 ]; then
21+
echo "${gpu_name}"
2222
else
2323
echo "${gpu_name}${gpu_nums}"
2424
fi
@@ -28,3 +28,4 @@ main() {
2828
print_gpu_name
2929
}
3030
main "$@"
31+

0 commit comments

Comments
 (0)