ubuntu 18.04吐血安装anaconda3+cuda10.1+cudnn7.6.5+torch-1.5.1+ torchvision-0.6.1

注:需要亲自上手一编,因为是在是太复杂了,每个人的机器情况不一样,需要找到适合的版本,仅参考互联网。

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

从上到下输出7 6 5即表示cudnn7.6.56.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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值