1. 安装nvidia驱动
2. 安装nvidia-docker
参考https://blog.csdn.net/u011622208/article/details/103458951
3. 安装GPU版pytorch
- 安装python,pip,numpy
# 首先更新源
$ apt-get update
# 查看python版本
$ apt-cache madison python
# 选择一个版本,比如 2.7.12-1~16.04
# 安装python
$ apt-get install python=2.7.12-1~16.04
# 安装pip, 如果是python2.7,最好不要更新pip
$ apt-get install python-pip
# 安装numpy
apt-get install python-numpy
-
安装pytorch
pip --default-timeout=100 install torch==0.4.1 -i https://pypi.mirrors.ustc.edu.cn/simple/
–default-timeout:设置超时的时间
-i: 设置用国内源 -
测试
root@aefab7b2cd58:~# python
Python 2.7.12 (default, Oct 8 2019, 14:14:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
True
>>>
生成镜像(可选)
docker commit -m 'GPU pytorch' -a 'chenjun' aefab7 chenjun/pytorch041
```
## reference
1.[https://blog.csdn.net/mumoDM/article/details/82503022](https://blog.csdn.net/mumoDM/article/details/82503022)