1. 程式人生 > >安裝nvidia-docker

安裝nvidia-docker

搭建nvidia-docker執行環境-Ubutu16.04

安裝 nvidia-docker


# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containersdocker 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 repositoriescurl -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# Install nvidia-docker2 and reload the Docker daemon configurationsudo apt-get install -y nvidia-docker2

sudo pkill -SIGHUP dockerd

//安裝ubuntu,配置caffe所需環境

sudo nvidia-docker search ubuntu

sudo nvidia-docker pull ubuntu


使用dockerfile生成映象
 

本文使用的dockerfile檔案如下:

FROM laika/ubuntu:base_image

LABEL maintainer 'wanghq'

ENV PYTHONPATH=‘/install_src/pyfaster-rcnn/python’

執行:sudo docker build -t "ubuntu:V1"

//啟動容器

sudo nvidia-docker run -it--privileged=true--name=wanghq ubuntu:V1 /bin/bash

//注意:此處必須新增--privileged=true使得容器真正獲取主機硬體資源,包括GPU顯示卡資源


 

[email protected]:~$ nvidia-docker

 

開發GPU應用程式

 

對於CUDA開發,你可以先從Dockerhub提取nvidia / cuda映象。

[email protected]:~$ nvidia-docker run --rm -ti nvidia/cuda:8.0 nvidia-smi8.0: Pulling from nvidia/cuda

別為Docker本地實現不支援GPU發愁,解決方案在此!