I’ve been wanting to learn CUDA recently. Here are my notes on setting up the environment.
- Create an environment. We’re just using Conda for environment isolation here — no Python needed.
$ conda create -n cuda-dev
$ conda activate cuda-dev
- Check the CUDA version with
nvidia-smi. Note that this version is the maximum CUDA version supported by the driver, not the CUDA runtime version we’ll install later. When installing, make sure the CUDA runtime version ≤ the driver version.
$ nvidia-smi
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.183.01 Driver Version: 535.183.01 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
- Install a specific CUDA version.
$ conda install cuda -c nvidia/label/cuda-11.8.0
- Check the
nvccversion to confirm the driver supports this CUDA version.
$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:33:58_PDT_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0
- The CUDA installed above does not include development headers and other build-time components. Install the following package as well:
conda install cuda-cudart-dev -c nvidia
The installation of
cuda-cudart-devis based on the instructions here.