Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

HowTo | NVIDIA GPU and nvidia docker2

iksooman edited this pageMay 23, 2023 ·11 revisions

How to install GPU Driver and CUDA driver

References:

If your Computer has NVIDIA Graphic cards, Install NVIDIA Graphic Driver to improve Graphics related performance.

Step 01: Disablenouveau driver on your system

Disablenouveau driver that is loaded by default as generic graphic driver.

Run following command as root or using sudo;

$ sudo update-pciids$ sudo lsmod| grep nouveaunouveau              1949696  0mxm_wmi                16384  1 nouveauwmi                    32768  2 mxm_wmi,nouveauvideo                  49152  1 nouveaui2c_algo_bit           16384  1 nouveauttm                   106496  1 nouveaudrm_kms_helper        184320  1 nouveaudrm                   491520  4 drm_kms_helper,ttm,nouveau
  • lsmod: program to show the status of modules in the Linux Kernel

if the result containsnouveau, do following step

$ sudo vi  /etc/modprobe.d/blacklist-nouveau.conf# add to the end (create new if it does not exist)blacklist nouveauoptions nouveau modeset=0$ sudo update-initramfs -u$ sudo reboot

Step 02 : Check Driver Version for your Graphic Card on NVIDIA official site

# confirm the cards on your computer$ sudo update-pciids$ lspci| grep VGA01:00.0 VGA compatible controller: NVIDIA Corporation GA102 [GeForce RTX 3090] (rev a1)

NVIDIA Driver is provided on Ubuntu official repository.Before installing, make sure the Driver Version for your Graphic Card on NVIDIA official site as follows:

For GeForce RTX 3090, driver version info from thehttps://www.nvidia.com/Download/driverResults.aspx/193095/en-us/

LINUX X64 (AMD64/EM64T) DISPLAY DRIVER

Version:515.76
Release Date:2022.9.20
Operating System:Linux 64-bit
Language:English (US)
File Size:347.96 MB
# install the driver for your card$ sudo apt -y install nvidia-driver-515
# verify installation to show Graphic cards' status$ nvidia-smi

If you got the following error message, reboot your system or please refer to [Failed to initialize NVML: Driver/library version mismatch] link.

Failed to initialize NVML: Driver/library version mismatch

Step 03: CUDA driver Installation


How to install nvidia-docker2

Refer to following reference for up-to-date information

Installation of nvidia-dcoker2

#-----------------------------------# repo and GPG key configuration#-----------------------------------$ distribution=$(. /etc/os-release;echo$ID$VERSION_ID)\&& curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey| sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg\&& curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list|\             sed's#deb [https://#deb](https://github.com/#deb) [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] [https://#g'](https://github.com/#g') | \  sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list#-----------------------------------# nvidia-docker install with apt-get#-----------------------------------$ sudo apt-get update$ sudo apt-get install -y nvidia-docker2$ sudo apt-get install -y nvidia-container-toolkit#(Optional, Recommend to execute it for using GPU in Docker)#-----------------------------------# Configure the Docker daemon#-----------------------------------$ sudo nvidia-ctk runtime configure --runtime=docker#(Optional, Recommend to execute it for using GPU in Docker)#-----------------------------------# restart docker service#-----------------------------------$ sudo systemctl restart docker

How to check installation of nvidia-docker

$ docker run --rm --gpus all ubuntu:18.04 nvidia-smi

example output

+-----------------------------------------------------------------------------+| NVIDIA-SMI 460.73.01    Driver Version: 460.73.01    CUDA Version: 11.2     ||-------------------------------+----------------------+----------------------+| 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  GeForce RTX 3090    Off  | 00000000:01:00.0  On |                  N/A || 48%   44C    P8    36W / 370W |    671MiB / 24267MiB |      4%      Default ||                               |                      |                  N/A |+-------------------------------+----------------------+----------------------+                                                                               +-----------------------------------------------------------------------------+| Processes:                                                                  ||  GPU   GI   CI        PID   Type   Process name                  GPU Memory ||        ID   ID                                                   Usage      ||=============================================================================|+-----------------------------------------------------------------------------+

How to use GPU resources in your docker container

References:

You can specify GPU resource when executegit run commands as follows:

using --gpus option

$ docker run --rm --gpus all ubuntu:18.04 nvidia-smi

If you want to use specific GPU, you can use the GPU device number0,1,2, etc. instead ofall.

$ docker run --rm --gpus 0 ubuntu:18.04 nvidia-smi

using --runtime and environment variable

You should specifyNVIDIA_VISIBLE_DEVICES environment varialbe with--runtime option

$ docker run --rm --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all ubuntu:18.04 nvidia-smi

Also you can specify the GPU device number instead ofall as follows:

$ docker run --rm --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=0 ubuntu:18.04 nvidia-smi

Enabling GPU access with Compose

References

👉Note

  • This page might contain some wide rendered images. If you want to see the whole contents with wider page, please useWide GitHub extension of Chrome.
  • If you are experiencing the error on rendered images due to the low-bandwith Internet delay, please use F5 function key for refreshing current page.
Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp