hans

hans

[Docker] Installing GPU graphics card driver, CUDA, and CUDNN on Ubuntu 14.04 image.


There is an important issue that needs to be addressed upfront.

I have been unsuccessful in installing this at my company. The nvidia-smi command does not display GPU information and indicates that the driver and library versions are incompatible.

Later, I discovered the problem.

** The host machine's graphics card driver version must match the container's graphics card driver version!!! **

** 1. Pull the Ubuntu 14.04 image **

sudo docker pull ubuntu:14.04

** 2. Install nvidia-docker (this step is optional, if done, you can start using the nvidia-docker command in the future, if not, you can still use the GPU by adding the --privileged command in the third step) **

Link: https://github.com/NVIDIA/nvidia-docker

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
nvidia-docker run --rm nvidia/cuda nvidia-smi

** 3. Create a container and enter the Ubuntu image with true root privileges **

docker run -it --privileged=true ubuntu:14.04

Here, I will explain the privileged parameter. When set to true, it allows the root of the docker to have true root privileges, enabling access to the host machine's hardware, and even allowing you to use docker within docker.

** 4. Open a new terminal and copy the prepared CUDA installation package and CUDNN compressed package to the container **

docker ps
docker cp cuda.deb {@CONTAINER ID}:/root/
docker cp cudnn.tgz {@CONTAINER ID}:/root/

5. Return to the container's terminal and follow the instructions in the middle of the article at the following link to install CUDA and CUDNN

【Caffe】Caffe, CUDA, cuDNN Installation Guide, and Solutions to Various Problems (Ubuntu 14.04)

** 6. Save changes to a new image **

exit # Exit the container
docker ps -a # View the container ID (first four digits: xxxx)
docker commit xxxx ubuntu:gpu

** 7. The image I uploaded: **

docker pull renhanchi/ubuntu

This image is based on Ubuntu 14.04 and primarily includes:

nvidia:375.66

CUDA:8.0

CUDNN:5.1

caffe

tensorflow-gpu:1.1

Remember to use the command from step 3 when running the image!!!

** 8. Save and load local images **

docker save imageID > filename
docker load < filename

docker export containID > filename
docker import - filename

The first method, saving the image through the image, will preserve the operation history and allow you to roll back to previous versions.

The second method, saving the image through the container, will not preserve the operation history, resulting in a smaller file size.

When using the second method, if the third step command does not work, you may encounter the following error message: docker: Error response from daemon: No command specified.

In that case, you can use the following command instead:

docker run -it --privileged=true ubuntu:container /bin/bash
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.