Make sure you have installed the NVIDIA driver and a supported version of Docker for your distribution.
1) Install CUDA on Ubuntu 16.04 1
a) Remove Nouveau Driver
Set Disable Nouveau Driver to avoid conflict with NVidia Driver
$ sudo apt-get remove nvidia* && sudo apt autoremove
$ sudo apt-get install dkms build-essential linux-headers-generic
Insert as follows in /etc/modprobe.d/blacklist.conf
$ sudo vi /etc/modprobe.d/blacklist.conf
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
$ echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
rebuild kernel
$ sudo update-initramfs -u
$ sudo reboot
b) Install Nvidia driver and CUDA
change to console using ctrl + alt + F1 key just after reboot
and EXIT GUI service.
$ sudo service lightdm stop
$ sudo ./cuda_..._linux.run
Insert below 2 lines in ~/.bashrc
export PATH=$PATH:/usr/local/cuda-9.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64
2) How To Install and Use Docker on Ubuntu 16.04 2
a) Installing Docker
First, add the GPG key for the official Docker repository to the system:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker repository to APT sources:
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Next, update the package database with the Docker packages from the newly added repo:
$ sudo apt-get update
Make sure you are about to install from the Docker repo instead of the default Ubuntu 16.04 repo:
$ apt-cache policy docker-ce
$ sudo apt-get install -y docker-ce
$ sudo systemctl status docker
b) Executing the Docker Command without Sudo (optional)
$ sudo usermod -aG docker ${USER}
3) NVIDIA Container Runtime for Docker 3
a) If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
$ docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
$ sudo apt-get purge -y nvidia-docker
b) Add the package repositories
$ 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-get update
c) Install nvidia-docker2 and reload the Docker daemon configuration
$ sudo apt-get install -y nvidia-docker2
$ sudo pkill -SIGHUP dockerd
d) Test nvidia-smi with the latest official CUDA image
$ docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi
4) TEST MNIST on Docker
make directory to download MNIST dataset (it'll be used in docker)
$ mkdir ~/data
Run DIGITS and download/extract MNIST dataset
$ nvidia-docker run --name digits -d -v ~/data:/data -v ~/digits-jobs:/jobs -p 5000:5000 nvidia/digits && \
docker exec -it digits python -m digits.download_data mnist /data/mnist
'[ 프로그래밍 ]' 카테고리의 다른 글
Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1 (0) | 2018.12.05 |
---|---|
초보를 위한 도커 안내서 (0) | 2018.10.22 |
MAC에서 QT + CUDA 사용하기 (1) | 2014.07.17 |