Skip to main content

Setting Up RamaLama with CUDA Support on Linux systems

This guide walks through the steps required to set up RamaLama with CUDA support.

Install the NVIDIA Container Toolkit

Follow the installation instructions provided in the NVIDIA Container Toolkit installation guide.

Installation using dnf/yum (For RPM based distros like Fedora)

  • Install the NVIDIA Container Toolkit packages
sudo dnf install -y nvidia-container-toolkit
  • Update the packages list from the repository
sudo apt-get update
The NVIDIA Container Toolkit is required for WSL to have CUDA resources while running a container.

Setting Up CUDA Support

For additional information see: Support for Container Device Interface

Generate the CDI specification file

Check the names of the generated devices

Open and edit the NVIDIA container runtime configuration:
Generate a new CDI specification after any configuration change most notably when the driver is upgraded!

Testing the Setup

Based on this Documentation: Running a Sample Workload

Test the Installation

Run the following command to verify setup:

Expected Output

Verify everything is configured correctly, with output similar to this:
On systems that have SELinux enabled, it may be necessary to turn on the container_use_devices boolean in order to run the nvidia-smi command successfully from a container.
To check the status of the boolean, run the following:
If the result of the command shows that the boolean is off, run the following to turn the boolean on:

CUDA_VISIBLE_DEVICES

RamaLama respects the CUDA_VISIBLE_DEVICES environment variable if it’s already set in your environment. If not set, RamaLama will default to using all the GPU detected by nvidia-smi. You can specify which GPU devices should be visible to RamaLama by setting this variable before running RamaLama commands:
This is particularly useful in multi-GPU systems where you want to dedicate specific GPUs to different workloads. If the CUDA_VISIBLE_DEVICES environment variable is set to an empty string, RamaLama will default to using the CPU.
To revert to using all available GPUs, unset the environment variable:

Troubleshooting

CUDA Updates

On some CUDA software updates, RamaLama stops working complaining about missing shared NVIDIA libraries for example:
Because the CUDA version is updated, the CDI specification file needs to be recreated.

See Also

ramalama(1), podman(1)
Jan 2025, Originally compiled by Dan Walsh <dwalsh@redhat.com>