Nvidia-docker built environment on the linux server

docker corresponding to one container, which may be constructed in accordance with respective operating environment you need operating environment, isolated from each other between the respective environments at this time, there would not need to run a new code when the destruction of the original code required to run environment, isolated from each other between the respective environment, if a container which is isolated as

Since the docker is only suitable for the CPU running above, the need for servers running on top of the GPU, which provides a nvidia-docker

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

 

After how to build the nvidia-docker in the server sub-accounts above, in all places Baidu talking about are not the same, therefore, on Google access to the relevant documents, will build the nvidia-docker method on the server sub-account set forth below

Simply put, nvidia-docker steps to install a total of three steps:

Install NVIDIA driver
Install docker
Install nvidia-docker
  • Install the graphics driver

Our server even for most servers, this step is essential when installed, so this step we ignore the direct, specific questions can Baidu

 

  • Installation docker

docker available in two versions: Office Community (CE) and Enterprise Edition (EE), as NVIDIA graphics drivers, we need to know to choose the right version of linux installation files, the installed version is installed on top of the community edition ubuntu16.04

Installation steps docker

  • First of all, we need to exist in the docker remove old version on your computer, you can determine if this is your first time docker installed on your machine, then this step can be omitted, otherwise you'd better look at the implementation of the following The command
sudo apt-get remove docker docker-engine docker.io

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

  • Next, we will install docker, recommended to install docker from the repository (knowledge base) inside, this can be achieved when a new version appears, we can easily get updates from the repository inside

         We docker from the repository to install it, we need to first establish a docker repository, usually, we need to update the apt package

  • Update apt package index
sudo apt-get update
  • Then, apt to allow the installation package via 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 the following instruction is output 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
sudo apt-key fingerprint 0EBFCD88
  •  Next, tell apt with stable repository by running the following command
sudo add-apt-repository \
    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
     (usb_release -cs) \
     stable"
  • Here, we have completed the establishment of the knowledge base, then, we will update the apt package index and installation Docker CE
sudo apt-get update && apt-get install docker-ce

Then after this step is, wait for the installation to wait for the installation, download a long time, continue to wait

 

  • After installing docker, of course we need to test our installation is successful

Whether to use the famous hello-world test we installed a mirror to the success of docker

sudo docker run hello-world

If you get the following interface, proved successful installation docker

 

  • Install nvidia-docker

In the next step, we will complete our work by installing nvidia-docker, which docker in a plug to help in the use of container in the GPU environment

First of all, 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 not previously been installed you can skip this step

 

Next, we will add the necessary repository, 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 successful installation of nvidia-docker we installed verify

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

If this is your first time using the following instructions, you can see docker are trying to download something

Here, all over the whole installation procedure

 

 

Extra! After the server once after the collapse of the card, re-install the graphics driver, turned out to be "pleasantly surprised" to find that my nvidia-docker environment actually gone, but the input

docker version

Display docker is there, so you only need to follow the previous installation steps to install the nvidia-docker can, after a successful installation will find before the experiment according to dockerfile built environment is still in, and lucky!

 

Reproduced in: https: //www.cnblogs.com/Cucucudeblog/p/10425978.html

docker相当于一个容器,其可以根据你所需要的运行环境构建相应的运行环境,此时各个环境之间彼此隔离,就不会存在在需要跑一个新的代码的时候破坏原来跑的代码所需要的环境,各个环境之间彼此隔离开,好像一个个容器将其隔离开一样

由于docker只针对在CPU上面跑的情况,对于需要在GPU上面运行的服务器,其提供了一个nvidia-docker

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

 

对于怎么在服务器子账户上面搭建nvidia-docker,在百度上个个地方讲的都不一样,因此,在谷歌上查阅了相关的文档之后,将在服务器子账户上搭建nvidia-docker的方法陈列如下

简单的来说,要安装nvidia-docker总共的步骤分为三步:

Install NVIDIA driver
Install docker
Install nvidia-docker
  • 安装显卡驱动

对于我们的服务器甚至大多数服务器来说,这一步都是在装机的时候必备的,因此这一步我们直接忽略,具体问题可以百度

 

  • 安装docker

docker有两种可用的版本:社区办(CE)和企业版(EE),正如英伟达显卡驱动器,我们需要知道linux版本来选择合适的安装文件,以下的安装版本是在ubuntu16.04上面安装社区版

安装docker步骤如下

  • 首先,我们需要将存在于电脑上的老的版本的docker移除,如果你可以确定这是你第一次在你的机器上安装docker,那么这一步就可以省略,否则你最好执行一下以下的命令
sudo apt-get remove docker docker-engine docker.io

如果docker没有在你的机器上安装,那么apt-get将会告诉你这个问题

  • 接下来,我们将安装docker,推荐从repository(知识库)里面安装docker,这样可以实现当新的版本出现的时候,我们也可以从repository里面很容易的获得更新

         我们为了从repository里面安装docker,我们需要首先建立docker repository,通常,我们需要更新apt包

  • 更新apt package index
sudo apt-get update
  • 然后,安装软件包以允许apt通过HTTP
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
  • 接下来,加入docker的官方GPG密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo pt-key add -
  • 验证下列指令输出的是9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
sudo apt-key fingerprint 0EBFCD88
  •  接下来,通过运行下面的指令告诉apt用stable repository
sudo add-apt-repository \
    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
     (usb_release -cs) \
     stable"
  • 在这里,我们就已经完成了对知识库的建立,接下来,我们将更新apt package index并且安装Docker CE
sudo apt-get update && apt-get install docker-ce

然后这一步过后就是,等待安装等待安装,会下载很久,继续等待

 

  • 安装完docker之后,当然我们需要验证一下我们所安装的是否成功

利用著名的hello-world 镜像来测验我们安装的docker是否成功

sudo docker run hello-world

如果得到如下的界面,证明docker安装成功

 

  • 安装nvidia-docker

在下一步,我们将通过安装nvidia-docker来完成我们的工作,其是在docker中的一个plug来帮助容器在GPU环境下的使用

首先,我们需要将已有的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

以前没有安装过的话这一步可以直接跳过

 

接下来,我们将加入必要的repository,然后更新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

 

最后,我们将安装nvidia-docker

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

 

安装成功之后,对我们所安装的nvidia-docker进行验证

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

如果这是你第一次用如下的指令,你可以看到docker正在尝试下载一些东西

到这里,整个安装步骤全部结束了

 

 

号外!在有一次服务器显卡崩了之后,重新安装显卡驱动之后,竟然“惊喜”地发现我的nvidia-docker环境竟然不在了,但是输入

docker version

时显示docker是存在的,因此就只需要按照前面的安装步骤安装nvidia-docker就可以,安装成功之后会发现之前根据dockerfile搭建的实验环境仍然是在的,万幸!

 

Guess you like

Origin www.cnblogs.com/klausage/p/11865054.html