Detailed explanation of the process of setting up nvidia-docker environment on Linux server

Detailed explanation of the process of setting up nvidia-docker environment on Linux server

Docker is equivalent to a container, which can build a corresponding operating environment according to the operating environment you need. At this time, each environment is isolated from each other, so there will be no need to destroy the environment required by the original running code when a new code needs to be run. Each environment is isolated from each other, just like each container isolating it.

Since docker is only for running on CPU, for servers that need to run on GPU, it provides an nvidia-docker

sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP docker

As for how to build nvidia-docker on a server subaccount, each place on Baidu has different explanations. Therefore, after consulting relevant documents on Google, the method of building nvidia-docker on a server subaccount is listed as follows

Simply put, there are three steps to install nvidia-docker:

Install NVIDIA driver
Install docker
Install nvidia-docker

Install the graphics driver

For our server and even most servers, this step is necessary when installing the machine, so we will ignore this step directly. For specific questions, you can search on Baidu.

Install Docker

There are two versions of Docker available: Community Edition (CE) and Enterprise Edition (EE). Just like the NVIDIA graphics driver, we need to know the Linux version to choose the appropriate installation file. The following installation version is to install the community version on Ubuntu 16.04

The steps to install Docker are as follows

First, we need to remove the old version of Docker on your computer. If you are sure that this is the first time you install Docker on your machine, then this step can be omitted. Otherwise, you'd better execute the following command

sudo apt-get remove docker docker-engine docker.io

If docker is not installed on your machine, apt-get will tell you this.

Next, we will install Docker. It is recommended to install Docker from the repository so that when new versions are released, we can easily get updates from the repository.

In order to install docker from the repository, we need to first create a docker repository. Usually, we need to update the apt package

Update apt package index

sudo apt-get update

Then, install the package to allow apt to communicate over HTTP

sudo apt-get install \
  apt-transport-https \
  ca-certificates \
  curl \
  software-properties-common

Next, add Docker's official GPG key

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo pt-key add -

Verify that the following command outputs 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88

sudo apt-key fingerprint 0EBFCD88

Next, tell apt to use the stable repository by running the following command:

sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
(usb_release -cs) \
stable"

At this point, we have completed the establishment of the knowledge base. Next, we will update the apt package index and install Docker CE

sudo apt-get update && apt-get install docker-ce

Then after this step, just wait for the installation. It will take a long time to download. Keep waiting.

After installing docker, of course we need to verify whether our installation is successful

Use the famous hello-world image to test whether our docker installation is successful

sudo docker run hello-world

If you get the following interface, it proves that Docker is installed successfully

Install nvidia-docker

In the next step, we will complete our work by installing nvidia-docker, which is a plug-in in docker to help containers use GPU environments.

First, we need to remove the existing nvidia-docker

docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volum={} | xargs -r docker
sudo apt-get purge -y nvidia-docker

If you have not installed it before, you can skip this step.

Next, we will add the necessary repositories and then update the apt package index

curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
sudo apt-key add -

curl -s -L https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64/nvidia-docker.list | \
sudo tee /etc/apt/sources.list.d/nvidia-docker.list

sudo apt-get update

Finally, we will install nvidia-docker

sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd

After the installation is successful, verify the nvidia-docker we installed

docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi

If this is your first time using the following command, you can see that Docker is trying to download something:

Here, the entire installation process is complete.

Breaking news! Once, after the server graphics card crashed, I reinstalled the graphics card driver and was surprised to find that my nvidia-docker environment was gone. However, I typed

docker version

It shows that docker exists, so you only need to follow the previous installation steps to install nvidia-docker. After the installation is successful, you will find that the experimental environment built according to the dockerfile is still there, fortunately!

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed tutorial for installing influxdb in docker (performance test)
  • Detailed explanation of Docker domestic image pulling and image acceleration registry-mirrors configuration modification
  • How to use Docker container to access host network
  • Detailed explanation of COPY and ADD commands in Dockerfile
  • How to write the best Dockerfile
  • Tutorial on installing Vagrant and Docker on Mac OS
  • Add port mapping after docker container starts
  • 10 bad habits to avoid in Docker container applications

<<:  Detailed tutorial for installing influxdb in docker (performance test)

>>:  Detailed explanation of multiple implementation methods of Mysql counting by conditions

Recommend

Practice of deploying web applications written in Python with Docker

Table of contents 1. Install Docker 2. Write code...

Summary of JavaScript custom object methods

Table of contents 1. Use object to create an obje...

How to implement a password strength detector in react

Table of contents Preface use Component Writing D...

Small problem with the spacing between label and input in Google Browser

Code first, then text Copy code The code is as fol...

How to implement on-demand import and global import in element-plus

Table of contents Import on demand: Global Import...

Detailed explanation of real-time backup knowledge points of MySQL database

Preface The need for real-time database backup is...

Start nginxssl configuration based on docker

Prerequisites A cloud server (centOS of Alibaba C...

Analysis of the process of building a cluster environment with Apache and Tomcat

In fact, it is not difficult to build an Apache c...

Summary of fragmented knowledge of Docker management

Table of contents 1. Overview 2. Application Exam...

Detailed explanation of how to use the vue verification code component

This article example shares the specific implemen...

Let IE6, IE7, IE8 support CSS3 rounded corners and shadow styles

I want to make a page using CSS3 rounded corners ...

JavaScript Composition and Inheritance Explained

Table of contents 1. Introduction 2. Prototype ch...

A complete list of meta tag settings for mobile devices

Preface When I was studying the front end before,...

Specific use of Linux dirname command

01. Command Overview dirname - strip non-director...