image.png

docker文档:Turn on GPU access with Docker Compose | Docker Docs
Nvidia-Official: Installing the NVIDIA Container Toolkit — container-toolkit 1.14.1 documentation
Nvidia-Docker-Images: nvidia/cuda Tags | Docker Hub

安装Nvidia显卡Docker驱动

  1. 检查Nvidia驱动是否安装:nvidia-smi

image.png

  1. 加入apt源:

    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/stable/deb/nvidia-container-toolkit.list | \
    sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
    sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list \
    && \
    sudo apt-get update
  2. 安装依赖:

    sudo apt-get update && apt-get install -y nvidia-container-toolkit
  3. 更新重启docker: sudo systemctl restart docker

  4. 运行Nvidia-Container测试是否安装成功: docker run --rm --gpus all nvidia/cuda:12.2.0-runtime-ubuntu20.04 nvidia-smi

image.png