If you want to run GPU-accelerated computing tasks on GPU-accelerated instances, such as scientific computing or large-scale parallel computing tasks, you must install the Compute Unified Device Architecture (CUDA) development runtime environment. CUDA provides a complete set of tools and libraries that can help you develop GPU-accelerated programs to maximize the computing power of NVIDIA GPUs, improve computing performance, and accelerate running efficiency. This topic describes how to manually install CUDA.
Background information
CUDA is a general-purpose parallel computing platform that is developed by NVIDIA. CUDA harnesses the processing power of GPUs to help you solve complicated computing problems. CUDA includes the CUDA instruction set architecture (ISA) and a parallel computing engine that runs inside GPUs. You can use CUDA together with the C, Fortran, and C++ programming languages to develop programs. The programs can run on processors that support CUDA and can deliver ultra-high performance. In addition, CUDA supports APIs of various programming languages, such as Java and Python.
Prerequisites
A GPU-accelerated instance is created. For more information, see Create a GPU-accelerated instance.
The driver version of your GPU-accelerated instance is compatible with the CUDA version that you want to install. For more information, see CUDA Toolkit and Corresponding Driver Versions.
Procedure
CUDA supports the following mainstream OSs: Windows and Linux. This section describes how to separately install CUDA on a GPU-accelerated Linux instance and a GPU-accelerated Windows instance. In this example, CUDA Toolkit 12.1.1 is installed.
Linux
Obtain the CUDA installation package.
Go to the CUDA Toolkit Archive page.
Find the CUDA version that is suitable for your driver and click the CUDA version.
The following figure shows CUDA Toolkit 12.1.1.
Configure parameters and obtain the download URL of the CUDA installation package.
Configure parameters based on your business requirements, such as the Operating System, Architecture, and Version parameters.
Parameter
Example
Operating System
Linux
Architecture
X86_64
Distribution
Ubuntu
Version
20.04
Installer Type
runfile (local)
Obtain the download URL of the CUDA installation package.
Install the CUDA package.
Use one of the following methods to log on to the GPU-accelerated instance.
Method
References
Workbench
Virtual Network Computing (VNC)
Paste the download URL obtained in Step 1 in the
wget
command and run the command to download the CUDA installation package.wget https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda_12.1.1_530.30.02_linux.run
ImportantThe download task requires approximately 5 to 10 minutes to complete. Wait until the task is complete.
Use one of the following modes and run the commands in sequence to install the CUDA package.
NoteIf you use a GPU-accelerated compute-optimized instance, you can manually install a Tesla driver. You can also use the built-in driver in the CUDA package, which can be automatically installed when you install the CUDA package.
If you use a vGPU-accelerated instance, you must manually install a GRID driver. A GRID driver cannot be automatically installed when you install the CUDA package. For more information, see Install an NVIDIA GRID driver.
Mode 1: Interactive installation
sudo chmod +x cuda_12.1.1_530.30.02_linux.run
sudo ./cuda_12.1.1_530.30.02_linux.run
After you enter accept as prompted, determine whether to install the CUDA built-in driver based on your business requirements:
If you use a GPU-accelerated compute-optimized instance on which a driver is installed, press the Enter key to clear the Driver option. The following figure shows the operation. Then, select Install to install the CUDA package.
ImportantIf you do not clear the Driver option, the CUDA built-in driver is automatically installed to overwrite the driver that already exists on the instance.
If you use a GPU-accelerated compute-optimized instance and you want to install the CUDA built-in driver on the instance, check whether the built-in driver is compatible with the GPU model of the instance. For more information, see Step 1: Download a Tesla driver. By default, the Driver option is selected. If the built-in driver is compatible with the GPU model, use the default setting of the Driver option. Then, select Install to install the CUDA package.
If you use a vGPU-accelerated instance, you must install a GRID driver on the instance. Before you proceed, we recommend that you check whether a GRID driver is already installed on the instance. For more information, see Install an NVIDIA GRID driver. After the GRID driver is installed, press the Enter key to clear the Driver option. The following figure shows the operation. Then, select Install to reinstall the CUDA package.
Mode 2: Silent installation
sudo chmod +x cuda_12.1.1_530.30.02_linux.run
sudo ./cuda_12.1.1_530.30.02_linux.run --toolkit --samples --silent
ImportantDuring installation in silent mode, the CUDA built-in driver cannot be automatically installed. You must manually install the driver that is required by your GPU-accelerated instance.
Run the following command to restart the GPU-accelerated instance:
reboot
Run the following commands in sequence to configure CUDA environment variables:
echo 'export PATH=/usr/local/cuda/bin:$PATH' | sudo tee /etc/profile.d/cuda.sh
source /etc/profile
Check whether CUDA is installed on the instance.
Run the
nvcc -V
command to check whether the CUDA version is valid.Run the following commands in sequence to test CUDA Samples and check whether CUDA is installed:
cd /usr/local/cuda-12.1/extras/demo_suite
./deviceQuery
If
PASS
is returned for the Result parameter, CUDA is installed.
Windows
Log on to the GPU-accelerated compute-optimized Windows instance.
Use one of the following methods to connect to the instance.
Method
References
Workbench
Virtual Network Computing (VNC)
Select the CUDA version that you want to install.
Go to the CUDA Toolkit Archive page.
Find the CUDA version that is suitable for your driver and click the CUDA version.
You must check whether the built-in driver in the CUDA package is compatible with the GPU model of the instance. For more information, see Step 1: Download a Tesla driver. The following figure shows CUDA Toolkit 12.1.1.
Configure parameters based on your business requirements, such as the Operating System, Architecture, and Version parameters.
Parameter
Example
Operating System
Windows
Architecture
X86_64
Version
Server 2022
Installer Type
exe (local)
Click Download to download the CUDA package.
Install the CUDA package.
Open the folder where the downloaded CUDA package is stored, double-click the installation file to start the installation, and then follow the on-screen instructions to install the CUDA package.
If the information that indicates the installation is complete appears, the CUDA package is installed.
References
After you create a GPU-accelerated instance, you can manually install a Tesla or GRID driver to drive GPUs to implement features, such as computing acceleration and graphics rendering. For more information, see Install an NVIDIA Tesla driver or Install an NVIDIA GRID driver.
A Tesla driver and specific CUDA tools can be automatically installed when you create a GPU-accelerated instance. For more information, see Tesla or GRID driver.