您现在的位置是:首页 > 文章详情

使用Docker安装GPU版本caffe2

日期:2019-07-12点击:432

使用Docker安装GPU版本caffe2
第一步 安装Docker
SET UP THE REPOSITORY

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

sudo apt-get update

sudo apt-get install \

apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common 

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"

INSTALL DOCKER CE

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io

apt-cache madison docker-ce

选一个 for example, 5:18.09.1~3-0~ubuntu-xenial
sudo apt-get install docker-ce= docker-ce-cli= containerd.io

sudo docker run hello-world

运行通过就OK

docker version

有版本提示就OK

第二步 安装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

Test nvidia-smi with the latest official CUDA image

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

输出显卡信息就OK

第三步 安装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
第四步 测试
python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"

返回Success就OK

python2 -c 'from caffe2.python import workspace; print(workspace.NumCudaDevices())'

返回1就OK

进入python输入

from caffe2.python import workspace

不报错就OK

 

作者:一个炼丹师
来源:CSDN
原文:https://blog.csdn.net/Andrwin/article/details/94736930
版权声明:本文为博主原创文章,转载请附上博文链接!

原文链接:https://yq.aliyun.com/articles/708821
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章