CUDA
A C/C++/Fortran parallel computing platform and application programming interface (API) that allows software to use graphics processing units (GPUs) for general purpose processing.
CUDA requires an environment module
In order to use CUDA, you must first load the appropriate environment module:
module load cuda
Warning
Due to disk space constraints, NVIDIA CUDA libraries are avaialble only on the login nodes and GPU nodes.
They are not available on general-purpose compute nodes. Be sure to specify the Slurm --gres:gpu=[1-4]
option when
submitting jobs to the cluster.
Compiling with CUDA#
Once you have loaded the CUDA module (module load cuda
), the nvcc
command will be available:
You can now use the nvcc
command to compile C/C++ code:
In the above example, the compiler option -arch sm_61
specifies the compute capability 6.1 for the Pascal micro-architecture.
Submit CUDA jobs#
CUDA jobs are similar to regular HPC jobs, with two additional considerations:
- You need to request GPU resources from the scheduler with the
--gres=gpu:1
option. - You need to load the CUDA module (
module load cuda
)
Below is an example job submit script for a CUDA job:
- Note you can change the number of GPUs you request by changing the number on the end (e.g.
--gres=gpu:2
). Most general access nodes have a maximum of two GPU cards. Owner accounts may have more. - If you need a specific version of the CUDA libraries, you can run
$ module avail cuda
on any node to see what versions are available and then update this line accordingly (e.g.module load cuda/10.1
).
CUDA Example#
The following CUDA code example can help new users get familiar with the GPU resources available in the HPC cluster.
Create a file called deviceQuery.cu
:
Compile the code:
Create the job submit script (gpu_test.sh
or some-such):
Submit the job:
Wait for the job to finish running. When it finishes, the output should look something like the following: