Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Monitor GPU Usage, Memory & Temperature

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

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

  1. Identify your GPU vendor and model. Run lspci | grep -i vga or lspci | grep -i nvidia to see which GPU is installed. This determines which tool you'll use.
  2. 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-535 on Ubuntu).
    • For AMD: install rocm-smi (part of ROCm) or use sensors (lm-sensors). On Ubuntu: sudo apt install rocm-smi-lib or sudo apt install lm-sensors.
  3. Run a one-time snapshot. For NVIDIA, run nvidia-smi. For AMD, run rocm-smi --showuse --showtemp --showmeminfo vram (or just rocm-smi for a summary). This shows current usage, memory, and temperature.
  4. Monitor in real-time (refresh every second). Use watch -n 1 nvidia-smi for NVIDIA, or watch -n 1 rocm-smi for AMD. Press Ctrl+C to stop.
  5. 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 with while true; do ...; sleep 5; done). For AMD, use rocm-smi --showuse --showtemp --showmeminfo vram --csv >> gpu_log.csv similarly.
  6. Monitor multiple GPUs. Both tools show all GPUs by default. To filter specific ones, use nvidia-smi -i 0,1 (GPU indices) or rocm-smi -i 0.
  7. 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,noheader and an if statement.
  8. Use a dashboard for persistent monitoring (optional). Tools like nvidia-smi dmon (NVIDIA) or rocm-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-smi will not work on AMD GPUs. Use rocm-smi or sensors.
  • 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=csv to 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-smi to see which processes are using the GPU with the --query-compute-apps option.
  • For AMD, sensors (after running sensors-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 the video or render group, 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 sensors for AMD or check if the driver is loaded correctly with lsmod | grep nvidia.
  • Output is blank or garbled: Ensure the GPU is not in a low-power state. Run a small GPU load (e.g., glxgears or 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 nvidia to 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.