Install nVidia driver :
On Ubuntu 18.04.2 :
HOWTO : Intel and nVidia GPUs on Ubuntu 18.04.1 LTS
On Kali Linux 2019.1 :
HOWTO : nVidia and HashCat on Kali Linux 2018.4
Uninstall docker.io (if any)
sudo apt remove docker docker-engine docker.io containerd runc docker-composeReady for docker-ce
On Ubuntu 18.04.2 :
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt updateOn Kali Linux 2019.1 :
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
echo "deb [arch=amd64] https://download.docker.com/linux/debian stretch stable" > /etc/apt/sources.list.d/docker-ce.list
apt updateReady for nvidia-docker2
On Ubuntu 18.04.2 :
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt updateOn Kali Linux 2019.1 :
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/debian9/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list
apt updateInstall docker-ce and nvidia-docker2
apt-cache madison docker-ce
apt-cache madison nvidia-docker2Find the most matched versions and the following settings are for my system at the time of this writing :
On Ubuntu 18.04.2 :
sudo apt install docker-ce=18.03.1-ce-0-debian docker-ce-cli=18.03.1-ce-0-debian containerd.io nvidia-docker2=2.0.3+docker18.03.1-1 nvidia-container-runtime=2.0.3+docker18.03.1-1On Kali Linux 2019.1 :
apt install docker-ce=18.03.1-ce-0-debian docker-ce-cli=18.03.1-ce-0-debian containerd.io nvidia-docker2=2.0.3+docker18.03.1-1 nvidia-container-runtime=2.0.3+docker18.03.1-1If the versions are not matched, the installation will be failed.
Install docker-compose
sudo apt install python3-pip
pip3 install docker-compose pip --ugradeConfigure docker-ce
sudo nano /etc/docker/daemon.jsonAdd the following in front of
"runtimes": { :"default-runtime": "nvidia",sudo systemctl enable docker
sudo systemctl start dockerBasic usage
docker run --runtime=nvidia --rm nvidia/cuda nvidia-smiRemark
Make sure the nvidia driver and CUDA versions in the host computer is equal or greater than the versions in docker containers. Otherwise, docker containers refuse to start.
That's all! See you.