当前位置:网站首页>Pytorch GPU 训练环境搭建
Pytorch GPU 训练环境搭建
2022-08-03 19:46:00 【叶赫那拉 赫敏】
之前⼀直使⽤ Tensorflow 训练模型,第⼀次训练Pytorch模型的时候,发现速度很慢,仔细观察,发现GPU 内存占⽤为0,基本没有使⽤GPU。
AssertionError: CUDA unavailable, invalid device 0 requested
cuda不可⽤报错,现实没有有效的驱动可使⽤
测试cuda是否配置正确
import torch
print(torch.cuda.is_available())
重新安装cuda
检测本地GPU CUDA版本 nvidia-smi

pip3 install torch1.9.0+cu101 torchvision0.10.0+cu101 torchaudio=0.9.0 -f
https://download.pytorch.org/whl/torch_stable.html
当前 torchvision0.10.0+cu101 版本必须是匹配的。如果版本不匹配,如上⾯的命令,则会出现错误

我们打开网站
https://download.pytorch.org/whl/torch_stable.html
查看所有版本

“cu101” 表示需要的CUDA版本
“torchvision-0.2.1” 可以看到我们可以适应的版本
其它字段信息,包含适配 python 版本,cpu 版本,或者是系统⽀持
conda install torch==1.8.1+cu101 torchvision==0.9.1+cu101
torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
如果安装还是报错的话
ERROR: Could not find a version that satisfies the requirement
torch1.8.1+cu101...
我们可以换下⾯这种安装⽅式
conda install -i https://pypi.tuna.tsinghua.edu.cn/simple torch===1.8.1
torchvision===0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
终于安装成功,满⼼欢⼼重新测试:

还是不对,这⼀次报错说我们的 CUDA 驱动版本太低了,⽽是 Pytorch 的版本和 CUDA 不匹配。
查看我们的 CUDA Version 为 10.0.130

再看下我们当前环境的 torch 版本


发现1.8.0版本对应的CUDA最低为10.2 版本,确实⽐我们的要训练环境要高,重新调整我们本地虚拟环境版本,我们稍微降低⼀下版本,Torch官⽹的版本只提供了CUDA 9.2和CUDA 10.1的版本,我的CUDA是10.0的。所以这里版本不对应导致Torch.cuda加速无法运行。

这⾥支持10.0版本为1.2.0版本,感觉有点低,升级⼀下CUDA版本到10.1版本


边栏推荐
- LeetCode 952. Calculate Maximum Component Size by Common Factor
- Matlab paper illustration drawing template No. 42 - bubble matrix diagram (correlation coefficient matrix diagram)
- 阿里巴巴政委体系-第五章、阿里政委体系建设
- 标准C语言学习总结11
- MySQL 主从,6 分钟带你掌握!
- 手把手教你定位线上MySQL慢查询问题,包教包会
- Standard C language learning summary 11
- 【统计机器学习】线性回归模型
- 【飞控开发高级教程6】疯壳·开源编队无人机-AI语音控制
- net-snmp编译报错:/usr/bin/ld: cannot find crti.o: No such file or directory
猜你喜欢
随机推荐
群辉查看硬盘存储占用的方式
MVC vs MVP
力扣刷题之有效的正方形(每日一题7/29)
嵌入式分享合集27
Postgresql源码(65)新快照体系Globalvis工作原理分析
力扣刷题之求两数之和
awk语法-02-运算、数组、格式化输出
【木马免杀】
List类的超详细解析!(超2w+字)
Detailed AST abstract syntax tree
阿里巴巴政委体系-第九章、阿里政委启示录
演讲议题及嘉宾重磅揭晓,TDengine 开发者大会推动数据技术“破局”
力扣刷题之数组序号计算(每日一题7/28)
1161 最大层内元素和——Leetcode天天刷【BFS】(2022.7.31)
Detailed steps for tensorflow-gpu2.4.1 installation and configuration
【夜莺监控方案】08-监控msyql集群(prometheuse+n9e+mysqld_exporter)
In-depth understanding of JVM-memory structure
Word另存为PDF后无导航栏解决办法
宁德时代2号人物黄世霖辞任副董事长:身价1370亿
Standard C language learning summary 11









