Skip to main content

Use instance type

Use gpu instance

To use a GPU-type instance, you must install the appropriate driver.
You can create an instance by using a GPU-dedicated OS image with the driver installed, or create an instance with a default image and then separately download and install a public driver. The following describes how to install the GPU driver and use the GPU by operating system.

The following describes how to install the GPU driver on the Linux operating system.

info

This guide is based on the Ubuntu 20.04 image and NVIDIA A100 currently provided by KakaoCloud.

Step 1. Install NVIDIA driver

Install the NVIDIA driver. The recommended driver and CUDA versions are as follows.

GPU typeNVIDIA versionCUDA version
NVIDIA A100450.80.02 or laterCUDA Toolkit 11.1 or later
info
  1. Run the command to check whether the instance where you want to install the NVIDIA driver has NVIDIA hardware.

    Command to search for NVIDIA hardware
    lspci | grep -i NVIDIA
  2. Check the driver versions available for installation.

    • If the installed driver is not the latest version, run the apt update -y command to update it.
    • If the message Command ‘ubuntu-drivers’ not found appears, enter the sudo apt install ubuntu-drivers-common command to install ubuntu-drivers-common.
      Command to check installable driver versions
      ubuntu-drivers devices
      Example of checking driver versions
      ubuntu-drivers devices
      **==** /sys/devices/pci0000:00/0000:00:04.0 **==**
      modalias : pci:v000010DEd000020B0sv000010DEsd0000134Fbc03sc02i00
      vendor : NVIDIA Corporation
      driver : nvidia-driver-515-server - distro non-free
      driver : nvidia-driver-470 - distro non-free
      driver : nvidia-driver-470-server - distro non-free
      driver : nvidia-driver-510-server - distro non-free
      driver : nvidia-driver-510 - distro non-free
      driver : nvidia-driver-450-server - distro non-free
      driver : nvidia-driver-515 - distro non-free recommended
      driver : xserver-xorg-video-nouveau - distro free builtin
  3. Select an available driver and proceed with the installation.

    Install driver
    sudo apt install nvidia-driver-470

    Image

  4. Reboot the instance.

    Reboot command
    sudo reboot
  5. Check the installed driver information.

    Command to check installed driver information
    nvidia-smi
    Example of checking installed driver information
    nvidia-smi
    +-----------------------------------------------------------------------------+
    | NVIDIA-SMI 470.141.03 Driver Version: 470.141.03 CUDA Version: 11.4 |
    |-------------------------------+----------------------+----------------------+
    | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
    | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
    | | | MIG M. |
    |===============================+======================+======================|
    | 0 NVIDIA A100 80G... Off | 00000000:00:05.0 Off | 0 |
    | N/A 33C P0 41W / 300W | 35MiB / 80994MiB | 0% Default |
    | | | Disabled |
    +-------------------------------+----------------------+----------------------+
    | 1 NVIDIA A100 80G... Off | 00000000:00:06.0 Off | 0 |
    | N/A 34C P0 43W / 300W | 35MiB / 80994MiB | 0% Default |
    | | | Disabled |
    +-------------------------------+----------------------+----------------------+

Step 2. Install NVIDIA CUDA Toolkit

Install the NVIDIA CUDA Toolkit.

  1. If you are reinstalling the CUDA Toolkit, prepare the following installation environment. For a new installation, start from step 2.

    a. Delete the existing CUDA-related settings.

    Command to delete CUDA settings
    sudo rm -rf /usr/local/cuda*

    b. If the following existing settings are present in ~/.bashrc or /etc/profile, delete them.

    Delete existing settings
    export PATH=$PATH:/usr/local/cuda-11.4/bin
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.4/lib64
    export CUDADIR=/usr/local/cuda-11.4

    c. After deleting all existing settings, run the nvcc -V command and check that the command does not run.

    Result of running nvcc -V command
    nvcc -V
    Command 'nvcc' not found, but can be installed with: sudo apt install nvidia-cuda-toolkit
  2. Select the CUDA Toolkit version to install from NVIDIA official site > CUDA Toolkit Archive. When selecting a version, you can check the Base Installer commands at the bottom.

    Image Select CUDA Toolkit version and check Base Installer commands

  3. Run the first line of the Base Installer commands to download the CUDA Toolkit installation file.

    Example command to download CUDA Toolkit installation file
    wget https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda_11.4.0_470.42.01_linux.run

    Result of running the Base Installer command to download the Toolkit installation file Result of running the Base Installer command to download the Toolkit installation file

  4. Run the second line of the Base Installer commands to execute the CUDA Toolkit installation file.

    • Executing the CUDA Toolkit installation file takes more than 1 minute.
    Command to run CUDA Toolkit installation file
     sudo sh cuda_11.4.0_470.42.01_linux.run
  5. Press the arrow keys to select Continue, then press Enter.

    Image Select Continue

  6. Enter accept, then press Enter.

    Image Enter accept

  7. Press Space to clear the Driver checkbox, select Install, then press Enter.

    • If existing settings are present, the message Existing installation of CUDA Toolkit 11.x found appears. In that case, select Upgrade all and press Enter.

    Image Select Install

  8. If the CUDA Toolkit is installed successfully, you can see the following screen.

    Image CUDA Toolkit installation complete

  9. Run the following commands to add environment variables related to the CUDA Toolkit.

    Command to add CUDA Toolkit environment variables
    sudo sh -c "echo 'export PATH=$PATH:/usr/local/cuda-11.4/bin' >> /etc/profile"
    sudo sh -c "echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.4/lib64' >> /etc/profile"
    sudo sh -c "echo 'export CUDADIR=/usr/local/cuda-11.4' >> /etc/profile"
    source /etc/profile
  10. Run the nvcc -V command to check the installed CUDA Toolkit.

    Image Result of checking CUDA Toolkit installation