How to Monitor GPU Usage, Memory & Temperature
In this article
Monitoring GPU usage, memory, and temperature on a server is essential for diagnosing performance issues, preventing thermal throttling, and ensuring hardware longevity. This guide covers both NVIDIA and AMD GPUs using command-line tools and simple one-liners. You'll need SSH access to the server and appropriate permissions (usually root or sudo) to install tools if not already present.
What You'll Need
- SSH client (e.g., Terminal on macOS/Linux, PuTTY on Windows)
- Server with NVIDIA or AMD GPU(s)
- Administrative (sudo) access to install monitoring tools
- Basic familiarity with the Linux command line
Step-by-Step
- Identify your GPU vendor and model. Run
lspci | grep -i vgaorlspci | grep -i nvidiato see which GPU is installed. This determines which tool you'll use. - Install the appropriate monitoring tool.
- For NVIDIA: install
nvidia-smi(usually comes with the NVIDIA driver). If missing, install the driver via your package manager (e.g.,sudo apt install nvidia-driver-535on Ubuntu). - For AMD: install
rocm-smi(part of ROCm) or usesensors(lm-sensors). On Ubuntu:sudo apt install rocm-smi-liborsudo apt install lm-sensors.
- For NVIDIA: install
- Run a one-time snapshot. For NVIDIA, run
nvidia-smi. For AMD, runrocm-smi --showuse --showtemp --showmeminfo vram(or justrocm-smifor a summary). This shows current usage, memory, and temperature. - Monitor in real-time (refresh every second). Use
watch -n 1 nvidia-smifor NVIDIA, orwatch -n 1 rocm-smifor AMD. PressCtrl+Cto stop. - Log data to a file for later analysis. For NVIDIA:
nvidia-smi --query-gpu=timestamp,utilization.gpu,memory.used,memory.total,temperature.gpu --format=csv >> gpu_log.csv(run in a loop withwhile true; do ...; sleep 5; done). For AMD, userocm-smi --showuse --showtemp --showmeminfo vram --csv >> gpu_log.csvsimilarly. - Monitor multiple GPUs. Both tools show all GPUs by default. To filter specific ones, use
nvidia-smi -i 0,1(GPU indices) orrocm-smi -i 0. - Set up alerts (optional). Use a script that checks temperature and sends a notification (e.g., email) if it exceeds a threshold. For example, a simple bash script with
nvidia-smi --query-gpu=temperature.gpu --format=csv,noheaderand anifstatement. - Use a dashboard for persistent monitoring (optional). Tools like
nvidia-smi dmon(NVIDIA) orrocm-smi --showall(AMD) provide continuous output. For a web-based dashboard, consider installing Prometheus with the nvidia_gpu_exporter, but that requires more setup.
Common Mistakes
- Assuming nvidia-smi is installed. It only comes with the NVIDIA driver. If you get "command not found", install the driver first.
- Using the wrong tool for AMD.
nvidia-smiwill not work on AMD GPUs. Userocm-smiorsensors. - Not checking permissions. Some tools require root to read certain sensors. If you see "Permission denied", run with
sudo. - Forgetting that memory usage includes VRAM only. The "memory" shown is GPU memory (VRAM), not system RAM. Don't confuse the two.
- Ignoring power draw. Temperature is important, but power draw (also shown in nvidia-smi) can indicate throttling or overuse.
Tips
- Use
nvidia-smi --query-gpu=utilization.gpu,memory.used,temperature.gpu --format=csvto get only the fields you need, making output easier to parse. - For continuous logging, use a cron job to run a snapshot every minute and append to a log file. That way you can correlate GPU usage with application performance later.
- Set a reasonable temperature threshold (e.g., 85°C for most GPUs) and check if your GPU hits it under load. If it does, improve cooling or reduce load.
- If you have multiple users on the server, use
nvidia-smito see which processes are using the GPU with the--query-compute-appsoption. - For AMD,
sensors(after runningsensors-detect) can show GPU temperature without ROCm, which is lighter.
Troubleshooting
- "nvidia-smi: command not found": Install the NVIDIA driver. On Ubuntu:
sudo apt update && sudo apt install nvidia-driver-535(or the latest version). Reboot after installation. - "rocm-smi: command not found": Install ROCm. On Ubuntu:
sudo apt install rocm-smi-lib. If that doesn't work, add the ROCm repository as per AMD's official instructions. - "Permission denied" when reading sensors: Run the command with
sudo. If that fails, check that your user is in thevideoorrendergroup, which often grants access to GPU devices. - Temperature shows 0 or N/A: Some GPUs (especially older or virtualized) do not expose temperature sensors. Try
sensorsfor AMD or check if the driver is loaded correctly withlsmod | grep nvidia. - Output is blank or garbled: Ensure the GPU is not in a low-power state. Run a small GPU load (e.g.,
glxgearsor a compute job) and re-check. - Multiple GPUs but only one shows: Check if the other GPU is disabled in BIOS or not detected by the OS. Run
lspci -nn | grep -i nvidiato see all devices.
Frequently Asked Questions
What is a safe GPU temperature?
Most GPUs are designed to operate up to 85-90°C under load. Sustained temperatures above 95°C may cause throttling or damage. Check your GPU's specifications for the exact maximum.
Does monitoring GPU usage affect performance?
No, tools like nvidia-smi and rocm-smi read hardware counters and have negligible overhead. Running them every second is fine for most workloads.
Can I monitor GPU temperature remotely?
Yes, you can SSH into the server and run the commands, or set up a web-based dashboard like Grafana with Prometheus exporters, but that requires additional configuration.
What is the difference between GPU memory and system memory?
GPU memory (VRAM) is dedicated memory on the graphics card, used for textures, framebuffers, and compute data. System memory (RAM) is the main system memory. They are separate and not interchangeable.
Why does my GPU show 0% utilization but high memory usage?
This can happen if the GPU is idle but has data cached in VRAM, or if a process is using memory without active compute (e.g., holding a model in memory). Check running processes with nvidia-smi to see which application is holding memory.
How can I monitor GPU temperature on a Windows server?
On Windows, you can use Task Manager (GPU section) or tools like GPU-Z or HWiNFO. For command-line, use nvidia-smi if you have the NVIDIA driver installed.