当前位置:网站首页>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】剑指 Offer II 009. 乘积小于 K 的子数组(滑动窗口、双指针)
Jingdong cloud released a new generation of distributed database StarDB 5.0
演讲议题及嘉宾重磅揭晓,TDengine 开发者大会推动数据技术“破局”
(十六)51单片机——红外遥控
LeetCode 952. Calculate Maximum Component Size by Common Factor
【leetcode】剑指 Offer II 008. 和大于等于 target 的最短子数组(滑动窗口,双指针)
Reveal how the five operational management level of hundreds of millions of easily flow system
机器学习中专业术语的个人理解与总结(纯小白)
Anaconda 虚拟环境迁移
Matlab论文插图绘制模板第42期—气泡矩阵图(相关系数矩阵图)
随机推荐
傅里叶变换(深入浅出)
安装anaconda并创建虚拟环境
ctfshow php features
The ecological environmental protection management system based on mobile GIS
基于移动GIS的环保生态管理系统
1-php学习笔记之数据类型
PHP according to the longitude and latitude calculated distance two points
Detailed demonstration pytorch framework implementations old photo repair (GPU)
matplotlib画polygon, circle
Reveal how the five operational management level of hundreds of millions of easily flow system
relocation R_X86_64_PC32 against,/usr/bin/ld: final link failed: Bad value
高位套牢机构,用友网络的信任危机是如何产生的?
演讲议题及嘉宾重磅揭晓,TDengine 开发者大会推动数据技术“破局”
CS免杀姿势
边缘盒子+时序数据库,美的数字化平台 iBuilding 背后的技术选型
pytorch框架实现老照片修复功能详细演示(GPU版)
高效目标检测:动态候选较大程度提升检测精度(附论文下载)
Postgresql中的pg_memory_barrier_impl和C的volatile
Detailed AST abstract syntax tree
从文本匹配到语义相关——新闻相似度计算的一般思路