Using CUDA

What is CUDA?

CUDA stands for Compute Unified Device Architecture. CUDA is a parallel computing architecure and C based programming language for general purpose computing on NVIDIA GPU’s

Which department machines support CUDA?

A list of machines with higher-end CUDA cards can be found on the CS filesystem at ~info/cuda_machines.

How do I configure my shell environment for CUDA development?

The NVIDIA graphics driver and CUDA compilier are already installed on machines that support CUDA. However, one must set some environment variables in order to run and write CUDA enabled programs.

This can be done using environment modules.

First, to see what versions of CUDA are available:

$ module avail cuda
------------------- /usr/local/modules -----------------------------------
cuda/7.5  cuda/9.1   cuda/10.1  cuda/11.0  cuda/11.2  cuda/11.4  cuda/11.7
cuda/8.0  cuda/10.0  cuda/10.2  cuda/11.1  cuda/11.3  cuda/11.6

To load the latest version of CUDA:

$ module load cuda

Or to load a specific version of CUDA:

$ module load cuda/11.4

Confirm:

$ module list
Currently Loaded Modulefiles:
 1) cuda/11.4

And:

$ nvcc --version | grep release
Cuda compilation tools, release 11.4, V11.4.152
How can I switch to a different version of CUDA?

If you have loaded a CUDA version and would like to switch to a different version:

$ module switch cuda/<VERSION>