rfswift config gpus
Give an existing container access to GPUs.
GPU access lets tools inside a container use your graphics card: CUDA or OpenCL computing, GPU-based signal processing, machine-learning inference, and faster rendering. You can request it when you create a container (--gpus), or add it later with rfswift config gpus.
The most common use creates a container with every GPU available:
rfswift container create -i penthertz/rfswift_resolute:sdr_full -n my_gpu --gpus allRF Swift detects whether your GPU is NVIDIA, AMD or Intel and sets up the container for it. GPU passthrough needs a Linux host.
What happens when you apply a change
Adding or removing a GPU on an existing container restarts it, so save your work first. On Linux with Docker, the change is applied in place after one sudo prompt. On Podman, the container is committed and created again; add --recreate to use that method on Docker too. The shorter spelling rfswift gpus also works. See config.
Synopsis
Create a container with a GPU (the vendor is detected):
rfswift container create -i IMAGE -n NAME --gpus allAdd a GPU to an existing container, or remove it:
rfswift config gpus add -c CONTAINER [-g SPECIFIER]
rfswift config gpus rm -c CONTAINERThe interactive wizard also has a “GPU passthrough” switch.
How it works
When you use --gpus all, or turn on “GPU passthrough” in the wizard, RF Swift:
- Reads
/sys/class/drm/card*/device/vendorand the vendor-specific device files. - Works out which GPU vendors are present.
- Sets up the container for each of them:
| Detected GPU | What RF Swift does |
|---|---|
| NVIDIA (vendor 0x10de) | Adds a Docker DeviceRequest with the nvidia driver (needs nvidia-container-toolkit) |
| AMD (vendor 0x1002) | Adds the /dev/kfd and /dev/dri devices and the cgroup rule c 226:* rwm |
| Intel (vendor 0x8086) | Adds the /dev/dri device and the cgroup rule c 226:* rwm |
| Several GPUs | Sets up every vendor it found |
Before you start
The GPU drivers and runtime go on the host, not inside the container.
NVIDIA GPUs
Prerequisites
-
Check that the NVIDIA drivers are installed on the host:
nvidia-smi -
Install the NVIDIA Container Toolkit.
On Ubuntu or Debian:
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \ sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \ sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \ sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list sudo apt-get update sudo apt-get install -y nvidia-container-toolkitOn Fedora or RHEL:
curl -s -L https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo | \ sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo sudo dnf install -y nvidia-container-toolkit -
Configure the runtime.
For Docker:
sudo nvidia-ctk runtime configure --runtime=docker sudo systemctl restart dockerFor Podman:
sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml nvidia-ctk cdi list # verify -
Check that a container can see the GPU:
docker run --rm --gpus all nvidia/cuda:12.0-base nvidia-smi
Examples
Check the GPU from inside a container:
rfswift container shell -c gpu_sdr -e "nvidia-smi"On a machine with several NVIDIA GPUs, give each container a specific one:
rfswift container create -i penthertz/rfswift_resolute:sdr_full -n sdr_gpu --gpus 0
rfswift container create -i penthertz/rfswift_resolute:sdr_full -n ml_gpu --gpus 1Check that CUDA works from PyTorch:
rfswift container shell -c gpu_sdr
python3 -c "import torch; print(f'CUDA: {torch.cuda.is_available()}, Device: {torch.cuda.get_device_name(0)}')"AMD GPUs (ROCm)
When RF Swift detects an AMD GPU (vendor 0x1002, or /dev/kfd is present), --gpus all adds /dev/kfd, /dev/dri and the cgroup rule c 226:* rwm.
Prerequisites
-
Install ROCm on the host (Ubuntu 22.04 or 24.04), then check it:
sudo apt-get update wget https://repo.radeon.com/amdgpu-install/latest/ubuntu/jammy/amdgpu-install_6.0.60000-1_all.deb sudo apt-get install ./amdgpu-install_6.0.60000-1_all.deb sudo amdgpu-install --usecase=rocm rocm-smi -
Add your user to the
renderandvideogroups, then log out and back in:sudo usermod -aG render,video $USER -
Check that the device files exist.
/dev/kfdis the compute interface; each/dev/dri/renderD*is one GPU:ls -l /dev/kfd /dev/dri/render*
Usage
Create a container with the GPU, or add it to an existing one:
rfswift container create -i penthertz/rfswift_resolute:sdr_full -n rocm_sdr --gpus all
rfswift config gpus add -c sdr_workCheck the GPU from inside the container:
rfswift container shell -c rocm_sdr
rocm-smi # List GPUs
rocminfo # Detailed GPU info
clinfo # OpenCL infoRF Swift adds these for you:
| What | Value | Purpose |
|---|---|---|
| Device | /dev/kfd |
Kernel Fusion Driver, the ROCm compute interface |
| Device | /dev/dri |
Direct Rendering Infrastructure, the GPU render nodes |
| Cgroup rule | c 226:* rwm |
Access to the DRI device files |
You can also add them by hand:
rfswift config bindings add -d -c sdr_work -s /dev/kfd -t /dev/kfd
rfswift config bindings add -d -c sdr_work -s /dev/dri -t /dev/dri
rfswift config cgroups add -c sdr_work -r "c 226:* rwm"ROCm with PyTorch
Install the ROCm build of PyTorch inside the container, then check the GPU:
rfswift container shell -c rocm_sdr
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.0
python3 -c "import torch; print(f'HIP available: {torch.cuda.is_available()}, Device: {torch.cuda.get_device_name(0)}')"Choosing specific GPUs
On a machine with several AMD GPUs, choose which ones tools see with HIP_VISIBLE_DEVICES inside the container:
rfswift container shell -c rocm_sdr
export HIP_VISIBLE_DEVICES=0 # First GPU only
export HIP_VISIBLE_DEVICES=0,1 # First two GPUs
rocm-smi # Shows only selected GPUsOr give the container only one GPU’s render node:
rfswift container create -i penthertz/rfswift_resolute:sdr_full -n rocm_gpu0 \
-s /dev/kfd:/dev/kfd,/dev/dri/renderD128:/dev/dri/renderD128 \
-g "c 226:* rwm"A profile for ROCm
name: rocm-sdr
description: SDR with AMD GPU (ROCm)
image: penthertz/rfswift_resolute:sdr_full
gpus: allIntel GPUs
When RF Swift detects an Intel GPU (vendor 0x8086), --gpus all adds /dev/dri and the cgroup rule c 226:* rwm. This covers integrated GPUs (UHD, Iris) and discrete ones (Arc), for OpenCL and oneAPI.
Prerequisites
-
Install the Intel compute drivers on the host (Ubuntu):
sudo apt-get install -y intel-opencl-icd intel-level-zero-gpu level-zero \ intel-media-va-driver-non-free libmfx1 libvpl2For an Intel Arc card, also install:
sudo apt-get install -y intel-gpu-tools -
Add your user to the
rendergroup:sudo usermod -aG render $USER -
Check the GPU:
ls -l /dev/dri/render* clinfo | grep "Device Name"
Usage
Create a container with the GPU, or add it to an existing one:
rfswift container create -i penthertz/rfswift_resolute:sdr_full -n intel_sdr --gpus all
rfswift config gpus add -c sdr_workCheck the GPU from inside the container:
rfswift container shell -c intel_sdr
clinfo | grep "Device Name" # OpenCL devices
vainfo # Video acceleration info
intel_gpu_top # GPU utilization (if intel-gpu-tools installed)To add it by hand:
rfswift config bindings add -d -c sdr_work -s /dev/dri -t /dev/dri
rfswift config cgroups add -c sdr_work -r "c 226:* rwm"Intel with oneAPI
rfswift container shell -c intel_sdr
pip3 install intel-extension-for-pytorch
python3 -c "import intel_extension_for_pytorch as ipex; print('Intel GPU available')"A profile for Intel GPUs
name: intel-sdr
description: SDR with Intel GPU
image: penthertz/rfswift_resolute:sdr_full
gpus: allProfiles work with any GPU
gpus: all in a profile works for every vendor, because detection runs when the container is created.
Comparison
All three vendors use the same --gpus all flag:
| NVIDIA | AMD (ROCm) | Intel | |
|---|---|---|---|
| RF Swift flag | --gpus all |
--gpus all |
--gpus all |
| What RF Swift adds | DeviceRequests (nvidia driver) | /dev/kfd + /dev/dri + cgroup |
/dev/dri + cgroup |
| Host requirement | nvidia-container-toolkit | ROCm drivers | Intel compute drivers |
| Compute API | CUDA, OpenCL | ROCm HIP, OpenCL | oneAPI, OpenCL |
| ML framework | PyTorch, TensorFlow | PyTorch (ROCm) | PyTorch (IPEX) |
| Choosing a GPU | --gpus 0,1 |
HIP_VISIBLE_DEVICES=0,1 (environment variable) |
Give specific renderD* nodes |
Engine compatibility
| Engine | NVIDIA | AMD/Intel |
|---|---|---|
| Docker (Linux) | Full (--gpus) |
Full (devices + cgroups) |
| Podman (Linux) | Supported (CDI) | Full (devices + cgroups) |
| macOS (any engine) | Not supported | Not supported |
| Windows (WSL2) | Not supported | Not supported |
--gpus passthrough needs a Linux host with direct access to the GPU. On macOS and Windows, container engines run inside a virtual machine without GPU access.
On a Mac with Apple Silicon
--gpus does not apply, but the global --gpu flag starts a separate Lima VM (krunkit, macOS 14 or later) that gives containers Vulkan compute. That VM has no USB passthrough. See engine and Known limits.
Podman with NVIDIA
RF Swift translates --gpus all into Podman’s CDI syntax (--device nvidia.com/gpu=all). Set it up once:
sudo apt-get install nvidia-container-toolkit
sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml
nvidia-ctk cdi list # verifyPodman with AMD or Intel
This works as with Docker, because device bindings and cgroup rules are standard Linux features:
rfswift --engine podman container create -i penthertz/rfswift_resolute:sdr_full -n rocm_sdr \
-s /dev/kfd:/dev/kfd,/dev/dri:/dev/dri \
-g "c 226:* rwm"Troubleshooting
NVIDIA: “could not select device driver”
The full error is Error: could not select device driver "nvidia" with capabilities: [[gpu]]. The NVIDIA Container Toolkit is missing or not configured. Install and configure it, then check:
sudo apt-get install nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
docker run --rm --gpus all nvidia/cuda:12.0-base nvidia-smiAMD: “permission denied” on /dev/kfd
ROCm commands fail with permission errors. Check the device permissions, make sure the cgroup rule is set, and check your groups on the host (they should include render and video):
ls -l /dev/kfd /dev/dri/render*
rfswift config cgroups add -c container -r "c 226:* rwm"
groupsIf it still fails, you may need to run the container as root or match the group IDs.
AMD: “no GPU agent found”
rocminfo shows no GPU. Check that the devices are in the container, add them if they are missing, and make sure ROCm works on the host first:
rfswift container shell -c container -e "ls -l /dev/kfd /dev/dri/"
rfswift config bindings add -d -c container -s /dev/kfd -t /dev/kfd
rfswift config bindings add -d -c container -s /dev/dri -t /dev/dri
rocm-smiIntel: “no OpenCL devices found”
clinfo shows no device. Check that /dev/dri is in the container, and add it with its rule if missing:
rfswift container shell -c container -e "ls -l /dev/dri/"
rfswift config bindings add -d -c container -s /dev/dri -t /dev/dri
rfswift config cgroups add -c container -r "c 226:* rwm"If needed, install the OpenCL driver inside the container:
apt-get install -y intel-opencl-icdThe GPU works with Docker but not in an RF Swift container
Check the GPU request Docker recorded for the container, then add the GPU with RF Swift (the vendor is detected):
docker inspect container --format '{{json .HostConfig.DeviceRequests}}'
rfswift config gpus add -c containerRelated commands
cgroups: device access rulesbindings: devices and folderscapabilities: Linux capabilitiesrun: create containers with--gpusrealtime: realtime mode for SDR performance