The CUDA Toolkit is a C language development environment for CUDA-enabled GPUs.
All managed Linux workstations but only useful on machines with high-end NVIDIA graphics cards which support CUDA.
Ubuntu 26.04 or newer
On Ubuntu 26.04 the recommended method for compiling and running CUDA code is to use docker. This requires a little initial setup, as described below.
Setup docker
If you have not yet done so, set up your per-user docker configuration.
Choose a suitable container
Run nvidia-smi to determine the CUDA version (e.g. 13.2) supported by your graphics card and driver. Search https://hub.docker.com/r/nvidia/cuda/tags for containers corresponding to that version: you need a "devel" container, and we recommend picking the latest version of Ubuntu for the underlying CUDA version. For example,
- nvidia/cuda:13.3.1-devel-ubuntu26.04
- nvidia/cuda:13.2.0-devel-ubuntu24.04
- nvidia/cuda:13.1.2-devel-ubuntu24.04
Running CUDA inside docker
To run a command such as nvcc inside your chosen docker container,
docker run --rm --gpus all -v "$PWD:$PWD" -w "$PWD" nvidia/cuda:13.2.0-devel-ubuntu24.04 nvcc hello.cu -o hello
where the arguments used are:
- --rm : remove the container after use (useful when you are just using the container as an environment to wrap running a command)
- --gpus all : make all gpus available inside the container
- -v "$PWD:$PWD" : make the present working directory available as a volume in the container at the same location
- -w "$PWD" : set the working directory inside the container to match the current directory
- nvidia/cuda:13.2.0-devel-ubuntu24.04 : the name of the container (see above)
- nvcc hello.cu -o hello : the command to run
(Optional) configure some shell aliases
You can provide shell aliases to avoid using long commands. For example, in ~/.bash_aliases you could define
alias cudacmd='docker run --rm --gpus all -v "$PWD:$PWD" -w "$PWD" nvidia/cuda:13.2.0-devel-ubuntu24.04'
after which (noting that changes to ~/.bash_aliases only take effect inside new terminals/login sessions) you could run
cd /home/USERNAME/helloworld # change to suitable code directory cudacmd nvcc hello.cu -o hello # compile binary cudacmd ./hello # run resulting binary
Ubuntu 24.04 or older
We have multiple cuda environment modules available, and it is likely that you want to use the version appropriate to the CUDA driver used by your graphics card. You can check that by running nvidia-smi, which will show you information about your Nvidia card including e.g. CUDA Version: 11.7, in which case you would want to module load cuda/11.7. It is likely that the first time you do this you will be told you need to run a command similar to sudo apt-get install cuda-toolkit-11-7; this is because the software is provided as a package from the Nvidia Ubuntu repository we make available on all managed linux workstations, and we then provide environment modules to properly set up e.g your PATH and CUDAXX environment.
Whilst in principle it is possible to install multiple CUDA versions simultaneously, they each require a signficant amount of disk space so you should check carefully before doing so.
Proprietary software; full details at http://developer.download.nvidia.com/licenses/general_license.txt.