注:需要亲自上手一编,因为是在是太复杂了,每个人的机器情况不一样,需要找到适合的版本,仅参考互联网。
anaconda 安装:
1.官网下载较慢,推荐添加清华大学源:
https://blog.csdn.net/weixin_44354586/article/details/89392951
2.anaconda 安装与配置:
https://blog.csdn.net/qq_35494379/article/details/105603832#t1
3.NVIDIA驱动安装:
https://blog.csdn.net/qq_35494379/article/details/105603832#t1
4.安装cuda10.1:
https://blog.csdn.net/BigData_Mining/article/details/99670642?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&dist_request_id=1328690.284.16165080379125663&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control
特别注意这两张图:
5.安装cuddn 7.6.5版本,首先要注意的是,
cuDNN Library for linux:
cuDNN Runtime Library for Ubuntu18.04 (Deb)
cuDNN Develpoper Library for Ubuntu18.04 (Deb)
cuDNN Code Samples and User Guide for Ubuntu18.04 (Deb)
都要下载安装。
仅看一下他的cuddn安装:
https://blog.csdn.net/ithinking110/article/details/105144202/
查看cudnn版本
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
6.pytorch的安装特别的恶心,需要使用pip的安装方式进行安装。可以避免出错。
pip install torch1.5.1+cu101 torchvision0.6.1+cu101 -f https://download.pytorch.org/whl/torch_stable.html
然后验证pytorch和torchvision是否安装成功,在python命令行输入import torch,无警告代表成功。
lirui@lirui:~/下载$ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
[GCC 7.2.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
import torch
1
2
3
4
5
6
至此,Pytorch安装成功!
最后,我们测试一下安装完这些能不能使用GPU加速:
打开Python,输入以下命令:
import torch as t
x = t.rand(5,3)
y = t.rand(5,3)
if t.cuda.is_available():
x = x.cuda()
y = y.cuda()
print(x+y)
1
2
3
4
5
6
7
最后输出下面的界面代表成功调用GPU加速,否则没有成功调用。
输出:
0.6720 0.8196 0.3007
1.1233 0.4768 0.9952
0.5416 0.4801 1.5302
0.3140 0.8989 0.1525
1.3961 1.2157 0.5667
[torch.cuda.FloatTensor of size 5x3 (GPU 0)]
装起来太难了,整个过程搞了快一天,真心好累
判断pytorch是否支持GPU加速
import torch as t
print(t.cuda.is_available())
输出为:True,即安装成功
7.解压缩的方式.tgz
tar zxvf
tar zxvf 文件名.tgz -C ./ 比如我的是:tar zxvf simple-examples.tgz -C ./
摘抄自互联网。留后续崩溃后自行查看
8.主要参考文献:
https://blog.csdn.net/qq_35494379/article/details/105603832#t1