ROCm and CUDA on Linux: Getting GPU Compute Working
nvidia-smi printing a table is not the same as a framework being able to use the card. The compute stack is separate from the display driver, and the failures are nearly always packaging or permissions rather than hardware.
Check what you have first
# which GPU, and which kernel driver is bound to it
lspci -nnk | grep -A3 -iE 'vga|3d|display'
# the device nodes, which is what actually matters
ls -l /dev/dri/
ls -l /dev/nvidia* 2>/dev/null
ls -l /dev/kfd 2>/dev/null
| Device node | Belongs to |
|---|---|
/dev/dri/cardN | Display, needs the video group |
/dev/dri/renderDN | Render and compute, needs render |
/dev/kfd | AMD compute, needs render |
/dev/nvidia0, /dev/nvidiactl | NVIDIA |
/dev/kfd is the AMD compute device. Its absence means ROCm will not work regardless of what else is installed, and our /dev guide covers what those nodes are.
NVIDIA and CUDA
Driver versus toolkit
The distinction that causes most of the confusion.
The driver includes the kernel module and libcuda.so, the runtime that lets a compiled program talk to the GPU. That is all you need to run things.
The toolkit adds nvcc, headers and development libraries. You need it to build CUDA code and generally not to run PyTorch, which ships its own CUDA runtime in the wheel.
# driver version and the CUDA version it supports
nvidia-smi
nvidia-smi --query-gpu=name,driver_version,memory.total --format=csv
# is the toolkit present
nvcc --version 2>/dev/null || echo "no toolkit, which may be fine"
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 620.73.04 Driver Version: 620.73.04 CUDA Version: 13.0 |
That CUDA version is the maximum the driver supports, not what is installed. A framework built against an older CUDA runs fine on a newer driver; the reverse does not.
# install the driver from your distribution, not NVIDIA's .run file
sudo dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda # Fedora, RPM Fusion
sudo apt install nvidia-driver-620 nvidia-utils-620 # Ubuntu
sudo pacman -S nvidia nvidia-utils # Arch
# the toolkit, only if you are compiling
sudo dnf install cuda-toolkit
sudo apt install nvidia-cuda-toolkit
Our NVIDIA drivers guide covers the driver properly, including the DKMS rebuild that must succeed after a kernel update and the Secure Boot signing that blocks an unsigned module.
# after any driver or kernel change, verify before rebooting
sudo dkms status
modinfo nvidia | grep -E '^version|^signer'
PyTorch not seeing the GPU
python -c 'import torch; print(torch.__version__, torch.cuda.is_available(), torch.version.cuda)'
# 2.x.y+cpu False None <- the usual cause
+cpu in the version means you installed the CPU-only build. pip install torch from the default index gives you that on many platforms.
# install the CUDA build explicitly
pip install torch --index-url https://download.pytorch.org/whl/cu126
Our Python versions guide covers keeping this in a virtual environment rather than system-wide, which matters because these packages are large and version-specific.
AMD and ROCm
# the kernel side is already in-tree
lsmod | grep amdgpu
ls -l /dev/kfd /dev/dri/renderD*
# the userspace stack
sudo apt install rocm-smi rocminfo rocm-opencl-runtime # Ubuntu, AMD repo
sudo dnf install rocm-smi rocminfo # Fedora
sudo pacman -S rocm-smi-lib rocminfo rocm-opencl-runtime # Arch
rocm-smi
rocminfo | grep -E 'Name:|gfx'
clinfo | grep -iE 'device name|version'
rocminfo showing your gfx target is the check that matters. Nothing works without it.
Groups, the usual blocker
id
# if render and video are missing, that is your problem
sudo usermod -aG render,video "$USER"
# then log out and back in, or
newgrp render
Group changes do not apply to your existing session. A user added to render who has not logged out still cannot see the GPU, which produces a confusing “works for root, fails for me” symptom. Our groups guide covers it.
Unsupported cards
AMD officially supports a short list, which excludes most consumer cards. The override frequently works anyway:
# tell ROCm to treat the card as a supported relative
export HSA_OVERRIDE_GFX_VERSION=11.0.0
# find your actual target first
rocminfo | grep gfx
| Your card | Try |
|---|---|
| RDNA 3, gfx110x | 11.0.0 |
| RDNA 2, gfx103x | 10.3.0 |
| RDNA 1, gfx101x | 10.1.0 |
This is unsupported. It works for a great many people and it means occasional crashes, wrong results in edge cases, and no help from AMD. Fine for experimenting, and something to know you are relying on.
# make it stick for a service
# [Service]
# Environment=HSA_OVERRIDE_GFX_VERSION=11.0.0
# PyTorch for ROCm
pip install torch --index-url https://download.pytorch.org/whl/rocm6.2
python -c 'import torch; print(torch.cuda.is_available(), torch.version.hip)'
PyTorch on ROCm still reports through torch.cuda, which is confusing and deliberate: the API is unchanged so code written for CUDA runs unmodified.
Containers
Where most compute actually runs, and the configuration differs per vendor.
NVIDIA
# the container toolkit, on the host
sudo dnf install nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
# for podman, CDI rather than a runtime hook
sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml
nvidia-ctk cdi list
# test
docker run --rm --gpus all nvidia/cuda:12.6.0-base-ubuntu24.04 nvidia-smi
podman run --rm --device nvidia.com/gpu=all nvidia/cuda:12.6.0-base-ubuntu24.04 nvidia-smi
The toolkit injects the host’s driver libraries and device nodes into the container, which is why the container image needs only the CUDA runtime and never a driver.
AMD
docker run --rm \
--device=/dev/kfd --device=/dev/dri \
--group-add video \
--security-opt seccomp=unconfined \
rocm/dev-ubuntu-24.04 rocm-smi
More manual: pass both devices, add the group, and ROCm’s images frequently want seccomp=unconfined because some of its ioctls are blocked by the default profile.
# podman rootless, which needs the group mapped
podman run --rm --device=/dev/kfd --device=/dev/dri \
--group-add keep-groups rocm/dev-ubuntu-24.04 rocm-smi
--group-add keep-groups is podman-specific and is how a rootless container inherits your render membership. Our rootless containers guide covers why that is awkward and our container networking guide covers the rest of the runtime.
# compose, NVIDIA
services:
train:
image: nvidia/cuda:12.6.0-runtime-ubuntu24.04
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
Our Docker Compose guide covers the file format.
Watching it work
# NVIDIA
nvidia-smi dmon
watch -n1 nvidia-smi
nvidia-smi --query-gpu=utilization.gpu,memory.used,temperature.gpu --format=csv -l 1
# AMD
rocm-smi --showuse --showmemuse --showtemp
watch -n1 rocm-smi
# either, the generic view
sudo intel_gpu_top # Intel
nvtop # all three vendors, htop-like
nvtop is worth installing. It handles NVIDIA, AMD and Intel, shows per-process GPU usage, and is far more readable than watching nvidia-smi.
Temperature matters under sustained compute. Our lm-sensors guide covers the thermal side, and a card throttling under load is a cooling problem rather than a software one.
When it does not work
# 1. is the driver loaded at all
lsmod | grep -E 'nvidia|amdgpu'
sudo dmesg | grep -iE 'nvidia|amdgpu|nvrm' | tail -20
# 2. did the module build, after a kernel update
sudo dkms status
uname -r
# 3. is Secure Boot blocking an unsigned module
mokutil --sb-state
sudo dmesg | grep -i 'module verification failed'
# 4. can your user reach the device
ls -l /dev/dri/renderD128 /dev/kfd 2>/dev/null
id
# 5. is the toolkit actually on PATH
command -v nvcc; echo "$LD_LIBRARY_PATH"
ldconfig -p | grep -E 'libcuda|libamdhip'
The causes in order of how often they are the answer:
- Group membership, and not having logged out since changing it
- A CPU-only framework build
- The kernel module not rebuilt after a kernel update, per our DKMS guide
- Secure Boot refusing an unsigned module, per our custom keys guide
- A container without the device passed through
- A genuine version mismatch between framework and driver
Note that the first five are configuration. Our running LLMs locally guide covers the layer above once this works, and our GPU drivers guide covers the kernel and userspace split that underlies all of it.
Frequently Asked Questions
Do I need a separate driver for GPU compute?
On NVIDIA the same kernel driver serves graphics and compute, and you additionally need the CUDA toolkit for building and some runtime libraries. On AMD the amdgpu kernel driver handles both, with the ROCm userspace stack installed separately. In both cases the graphics driver alone is not enough.
Why can my user not see the GPU when root can?
Because access to the device nodes is granted by group membership. On AMD you need the render and video groups, and on NVIDIA the device nodes are usually world accessible but a container or a restricted service may not have them. Check the group membership and whether you have logged out since adding it.
Can I use ROCm on an unsupported AMD card?
Frequently yes, by overriding the reported GFX version with the HSA_OVERRIDE_GFX_VERSION variable so ROCm treats the card as a supported relative. It works for many consumer cards and it is unsupported, so expect occasional crashes and no help from AMD when something misbehaves.
How do I pass a GPU into a container?
On NVIDIA install the container toolkit and use the gpus option, which injects the driver libraries and device nodes. On AMD pass the kfd and dri devices directly and add the container user to the render group. In both cases the host needs the driver and the container needs only the userspace libraries.
What is the difference between the CUDA driver and the CUDA toolkit?
The driver includes the kernel module and the runtime library that lets compiled programs talk to the GPU, which is all you need to run things. The toolkit adds the compiler, headers and development libraries, which you need to build CUDA code and generally do not need just to run PyTorch.
Why does PyTorch not see my GPU when nvidia-smi works?
Because nvidia-smi only proves the driver is loaded. The usual causes are a CPU-only build of the framework installed from the default package index, a CUDA version mismatch between the framework and the driver, or a container without the device passed through.