Skip to main content

Use instance by type

GPU instance usage

To use a GPU type instance, you must install the appropriate driver. You can create an instance using a GPU-specific OS image with drivers installed, or you can create an instance with a base image and then download and install the public drivers separately.

Here's how to use GPU by installing GPU driver for each operating system.

Follow these instructions to set up GPU drivers on Linux-based systems, specifically for Ubuntu 20.04 and NVIDIA A100 GPUs provided by KakaoCloud.

Step 1. Install NVIDIA driver

Install NVIDIA drivers. Recommended drivers and CUDA versions are as follows:

GPU typeNVIDIA versionCUDA version
NVIDIA A100450.80.02 and aboveCUDA Toolkit 11.1 or higher
info
  1. Run the command to check whether there is an NVIDIA device on the instance where you want to install the NVIDIA driver.

    NVIDIA device search command
    $ lspci | grep -i NVIDIA
  2. Check which driver versions can be installed.

    • If the installed driver is not the latest version, execute the update by executing the apt update -y command.

    • When 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 driver version to install
      $ ubuntu-drivers devices
      Example of checking driver version
      $ 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 installable driver and proceed with installation.

    Installing Driver
    $ sudo apt install nvidia-driver-470

    Image

  4. Reboot.

    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 NVIDIA CUDA Toolkit.

  1. When reinstalling the CUDA Toolkit, prepare the following installation environment. However, for new installations, proceed from the step 2.

    a. Delete existing CUDA-related settings.

    CUDA configuration deletion command
    $ sudo rm -rf /usr/local/cuda*

    b. If you have the following existing settings 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 to confirm that the command is not running.

    nvcc -V command execution result
    $ 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 see the Base Installer command at the bottom.

    Image Select CUDA Toolkit version and check Base Installer command

  3. Run the Base Installer command (first line) to download the CUDA Toolkit installation file.

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

    Result of executing file download command for Toolkit installation of Base Installer Result of executing file download command for Toolkit installation of Base Installer

  4. Execute the Base Installer command (second line) to run the CUDA Toolkit installation file.

    • It takes more than 1 minute to run the CUDA Toolkit installation file.

      File execution command for CUDA Toolkit installation
       $ sudo sh cuda_11.4.0_470.42.01_linux.run
  5. Press the arrow keys to select Continue and press Enter.

    Image Select Continue

  6. Type accept and press Enter.

    Image Enter accept

  7. Press Space to uncheck Driver, select Install, and press Enter.

    • If there is an existing configuration, the message Existing installation of CUDA Toolkit 11.x found will appear. If applicable, select Upgrade all and press Enter.

    Image Select Install

  8. If the CUDA Toolkit has been installed properly, you can see the following screen.

    Image CUDA Toolkit installation complete

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

    Command for adding environment variables related to CUDA Toolkit
    $ 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 CUDA Toolkit installation confirmation result