All Products
Search
Document Center

Elastic GPU Service:Install CUDA

Last Updated:Apr 26, 2024

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

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

  1. Obtain the CUDA installation package.

    1. Go to the CUDA Toolkit Archive page.

    2. Find the CUDA version that is suitable for your driver and click the CUDA version.

      The following figure shows CUDA Toolkit 12.1.1.

      CUDA.png

    3. Configure parameters and obtain the download URL of the CUDA installation package.

      1. 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)

      2. Obtain the download URL of the CUDA installation package.

        CUDA地址.png

  2. Install the CUDA package.

    1. Use one of the following methods to log on to the GPU-accelerated instance.

      Method

      References

      Workbench

      Connect to a Linux instance by using a password or key

      Virtual Network Computing (VNC)

      Connect to an instance by using VNC

    2. 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
      Important

      The download task requires approximately 5 to 10 minutes to complete. Wait until the task is complete.

    3. Use one of the following modes and run the commands in sequence to install the CUDA package.

      Note
      • If 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.

          Important

          If 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.

          image.png

        • 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.

          image.png

      • 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
        Important

        During 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.

    4. Run the following command to restart the GPU-accelerated instance:

      reboot
    5. 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
  3. Check whether CUDA is installed on the instance.

    1. Run the nvcc -V command to check whether the CUDA version is valid.

      CUDA版本.png

    2. 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.

      成功.png

Windows

  1. Log on to the GPU-accelerated compute-optimized Windows instance.

    Use one of the following methods to connect to the instance.

    Method

    References

    Workbench

    Connect to a Windows instance by using a password or key

    Virtual Network Computing (VNC)

    Connect to an instance by using VNC

  2. Select the CUDA version that you want to install.

    1. Go to the CUDA Toolkit Archive page.

    2. 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.

      image

    3. 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)

    4. Click Download to download the CUDA package.

      下载windowsCUDA.png

  3. 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.