Created
April 9, 2025 22:49
-
-
Save yunho-c/aa4448abe09520de5e3cdf0d47d77113 to your computer and use it in GitHub Desktop.
nvidia_vram_usage_by_user.sh
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 | |
# Shows which processes & users are consuming GPU memory for Nvidia GPUs. | |
echo "User, PID, Used Memory, GPU ID" | |
# Get the GPU processes information | |
nvidia-smi --query-compute-apps=pid,used_memory,gpu_bus_id --format=csv,noheader | while read line | |
do | |
# Extract PID from the line - use cut instead of awk for CSV format | |
pid=$(echo $line | cut -d',' -f1 | tr -d ' ') | |
# Get username for the process | |
username=$(ps -o user= -p $pid 2>/dev/null) | |
# Check if we got a username and the process exists | |
if [ ! -z "$username" ]; then | |
echo "$username, $line" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment