The solution of using gpu in docker (after installing the driver in the image and using nvidia-smi, it shows Failed to initialize NVML: Driver/library version mismatch)

Either install nvidia-driver inside the docker environment

But it is easy to be inconsistent with the external version, resulting in various errors such as version mismatch

It is better to use nvidia-docker, which is an official nVidia package for the convenience of using gpu in the docker image container:

1. Ensure that there is no nvidia driver in the docker environment to prevent inconsistent driver versions in subsequent configurations

        Find the image you want to use gpu, enter the image to delete the relevant driver package:

sudo apt-get --purge remove "*nvidia*"

2. Download ubuntu-container-toolkit from the docker image and install it and restart docker (otherwise docker cannot find the newly installed toolkit)

sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker

3. After installation, use docker run --gpus all in your startup container script to use nvidia-smi in the docker image

docker run --gpus all 你要用gpu的镜像名 nvidia-smi

Guess you like

Origin blog.csdn.net/qq_33859479/article/details/130231163