装caffe2还是用docker吧 ubuntu安装docker caffe2教程 detectron docker安装教程

编译总是出现各种问题,还是用docker快。Docker常用命令

1、Docker安装

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

sudo apt-get -y install \
  apt-transport-https \
  ca-certificates \
  curl
 

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

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

sudo apt-get update


sudo apt-get -y install docker-ce

测试:会出现docker的配置信息

docker info

2、nvidia-docker安装

# 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 https://nvidia.github.io/nvidia-docker/gpgkey | \
  sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/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 configuration
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd

测试:会出现gpu信息

# Test nvidia-smi with the latest official CUDA image
docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi

3、​​​caffe2安装

docker pull caffe2ai/caffe2


# to test
nvidia-docker run -it caffe2ai/caffe2:latest python -m caffe2.python.operator_test.relu_op_test


# to interact
nvidia-docker run -it caffe2ai/caffe2:latest /bin/bash

4、其他

修改docker权限,避免sudo:

sudo groupadd docker

sudo gpasswd -a ${USER} docker

sudo service docker restart

newgrp - docker

修改docker默认镜像存储路径:

$ sudo service docker stop

# 使用软连接到~/.docker文件夹,docker默认文件为/var/lib/docker
$ sudo mv /var/lib/docker ~/.docker

$ sudo ln -s ~/.docker /var/lib/docker

$ sudo service docker start

#连接成功后可以使用docker info查询Docker Root Dir是否改变

5、Detectron Docker安装

安装detectron docker时,不需要前面安装的caffe2,因为detectron在新建docker时自动pull一个caffe2 docker。

#docker build

git clone https://github.com/facebookresearch/detectron

cd detectron/docker

docker build -t detectron:c2-cuda9-cudnn7 .

#test

nvidia-docker run --rm -it detectron:c2-cuda9-cudnn7 python detectron/tests/test_batch_permutation_op.py

使用:

#映射主机路径,后台启用一个容器
nvidia-docker run -it --name detectron -v /data/sss/vqa:/vqa -d detectron:c2-cuda9-cudnn7

#运行容器
docker exec -it detectron /bin/bash

#执行代码
python2 tests/test_batch_permutation_op.py

 

你可能感兴趣的:(DL,tools)