Using GPU from a docker container?

后端 未结 10 1731
名媛妹妹
名媛妹妹 2020-11-27 09:12

I\'m searching for a way to use the GPU from inside a docker container.

The container will execute arbitrary code so i don\'t want to use the privileged mode.

<
10条回答
  •  没有蜡笔的小新
    2020-11-27 09:16

    Recent enhancements by NVIDIA have produced a much more robust way to do this.

    Essentially they have found a way to avoid the need to install the CUDA/GPU driver inside the containers and have it match the host kernel module.

    Instead, drivers are on the host and the containers don't need them. It requires a modified docker-cli right now.

    This is great, because now containers are much more portable.

    A quick test on Ubuntu:

    # Install nvidia-docker and nvidia-docker-plugin
    wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
    sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb
    
    # Test nvidia-smi
    nvidia-docker run --rm nvidia/cuda nvidia-smi
    

    For more details see: GPU-Enabled Docker Container and: https://github.com/NVIDIA/nvidia-docker

提交回复
热议问题