Driving the Ubuntu16.04 nvidia + nvidia-docker + cuda9 + cudnn7 installation

First, the host driver installation nvidia

Open a terminal, first remove the old drive:

sudo apt-get purge nvidia*

Disable comes nouveau nvidia drivers

sudo gedit /etc/modprobe.d/blacklist.conf

Whether facie Nouveau has been disabled

lsmod | grep again

If you have no show without explanation disabled, or continue to operate below

sudo vim /etc/modprobe.d/blacklist-nouveau.conf # Create a file (Note: Click the i button, now represents the content insertion)

And add the following:

new blacklist

new options modeset = 0

Note: Exit can be used in any of the two commands:

After press esc, or press shift + zz

After press esc, enter ": wq!" The contents inside double quotes

And then update the look:

sudo update-initramfs –u

Nouveau is an acknowledged has been disabled:

lsmod | grep again

No output anything, explained that it had successfully closed.

Close X-window service:

Ctrl + Alt + F1 to switch to the free Desktop command terminal: Here lightdm is your own display manager, it may be gdm, kdm, in the end is which one can use cat / etc / X11 / default-display-manager to view, and then modify, and turn off the display manager. Here below a few small steps recommended using a mobile phone camera, facing the picture to do, because you may not be familiar

sudo service lightdm stop

In this case officially entered the terminal interface:

Login: User accounts

Password: user password

installation:

cd / home / wlh / tmp # guide to download your driver where to put the address

sudo sh NVIDIA-Linux-x86_64-387.12.run

Installation following steps:

(1)accept

(2)contiuned install

Yes just fine after the default installation

Activate the display: (lightdm just my display manager, you might be in front of said gdm)

sudo service lightdm start

Then press Ctrl + Alt + F7 into the desktop operating

Checks for success

nvidia-smi

Two, docker installation

Download:

containerd.io_1.2.5-1_amd64.deb

docker-what-cli_18.09.4_3-0_ubuntu xenial_amd64.deb

docker-ce_18.09.4 3-0 ~ ~ ubuntu-xenial_amd64.deb

dpkg -i containerd.io_1.2.5-1_amd64.deb

dpkg -i docker-ce-cli_18.09.4_3-0_ubuntu-xenial_amd64.deb

dpkg -i docker-ce_18.09.4~3-0~ubuntu-xenial_amd64.deb

Try using a docker command is not successfully installed.

Establish docker Group:

$ sudo groupadd docker

The current user to join docker Group:

$ sudo usermod -aG docker $USER

Three, nvidia docker installation

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

Add the package repositories

curl -s -L  | \ sudo apt-key add - distribution=$(. /etc/os-release;echo $ID$VERSION_ID) curl -s -L $distribution/nvidia-docker.list | \ sudo tee /etc/apt/sources.list.d/nvidia-docker.list sudo apt-get update

5 perform the download command to download five packets to the current directory, copy these packets to the server.

apt download libnvidia-container1

apt download libnvidia-container-tools

apt download nvidia-container-runtime-hook

apt download nvidia-container-runtime

apt download nvidia-docker2

Executed on the server, dpkg -i libnvidia  NVIDIA  to install a five packets.

Test nvidia-smi with the latest official CUDA image

docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi

Fourth, the installation cuda9.0

First Quguan network download cuda9.0, 1.6G download the .run file, the download is complete you can officially installed.

Go to the download directory, add permissions to run the file:

chmod +x ./cuda_9.0.176_384.81_linux.run

Run the installation

sudo ./cuda_9.0.176_384.81_linux.run

Start the installation program, press the space bar has been to the last (Ctrl + c can choose to skip), do not worry, 99% of the time, the input accept to accept the terms

Note: The first time a reminder if you install the driver, select "n", the rest are "y"

After the installation is complete you need to add the environment, this step is very important! ! !

gedit ~/.bashrc

Add the following to the last:

export CUDA_HOME=/usr/local/cuda export PATH=$PATH:$CUDA_HOME/bin export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Test whether the installation is successful

nvcc -V

V. Installation cudnn7

Downloaded directly extract, extract will be a cuda folder, there are two documents include and lib64, the inside of the file copy to the appropriate directory / usr / local / cuda / inside lining. If you unpack at the local, do not move. Just add the file to give permission to read!

sudo chmod a+x /usr/local/cuda/include/cudnn.h sudo chmod a+x /usr/local/cuda/lib64/libcudnn*

And then update the Internet:

cd / usr / local / CUDA / lib64 /
sudo chmod + r libcudnn.so.7.0.5 # View .so own version of
sudo LN -sf libcudnn.so.7.0.5. libcudnn.so.7
sudo LN -sf libcudnn libcudnn.so .so.7
sudo ldconfig

View cudnn version, check whether the installed:

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

Sixth, the load packaged mirror

$ docker load<jq_tensorflow1.8-cuda9.0-cudnn7-devel-ubuntu16.04.tar

Seven, start the container

docker run --runtime=nvidia -it -v /home/dock/Downloads:/usr/Downloads name /bin/bash

Start error Solution:

Systemd drop-in file sudo mkdir -p /etc/systemd/system/docker.service.d sudo tee /etc/systemd/system/docker.service.d/override.conf <<EOF [Service] ExecStart= ExecStart=/usr/bin/dockerd --host=fd:// --add-runtime=nvidia=/usr/bin/nvidia-container-runtime EOF sudo systemctl daemon-reload sudo systemctl restart docker Daemon configuration file sudo tee /etc/docker/daemon.json <<EOF { "runtimes": { "nvidia": { "path": "/usr/bin/nvidia-container-runtime", "runtimeArgs": [] } } } EOF sudo pkill -SIGHUP dockerd 再去开启镜像,done。

Eight, the configuration container environment

Container running in the background exit command: CTRL + p + q

Background of the container to re-enter the command: docker exec -it [container id] / bin / bash

Guess you like

Origin www.cnblogs.com/wangkai333/p/11730007.html