当前位置:网站首页>WIN10环境下配置pytorch
WIN10环境下配置pytorch
2022-06-25 12:19:00 【辞树 LingTree】
利用Anaconda配置pytorch。
一,配置cuda以及cudnn(gpu加速)
(如果不没有nvidia显卡的话,只能用CPU,可忽略这一步)
在官网上下载好cuda以及cudnn后,开始配置cuda环境。
参考博客:win10下CUDA和CUDNN的安装(超详细)!亲测有效!_没有人喜欢一个人的博客-CSDN博客_安装cuda和cudnn
二,安装Anaconda
2.1 在官网下载并安装 Anaconda。
开始菜单中打开Anaconda中的Anaconda Prompt,出现(base),即安装成功,如下:

(配置失败请见文章末尾踩坑记录)
2.2 配置环境
安装成功后,停留在上面 Anaconda Prompt 页面上,输入
conda create -n pytorch python=3.8再接着输入y。将所需要的包安装完。
接着,我们输入:
conda activate pytorch可以看到

最左边的base,变成了pytorch。就进入了pytorch的编译环境。
2.3 pytorch的安装
在pytorch官网的对应部分选择我们对应的环境。

Pytorch Build:一般选择Stable(稳定版)。
Your OS:PC的操作系统。
Package:我们是在anaconda上安装,所以选Conda。
Language:选择Python。
Compute Platform:这里我们要根据我们在步骤一中配置的cuda的版本来选择。
win+r,输入cmd调出命令行窗口。输入
nvcc -V
nvidia-smi都可查看当前cuda版本。

在最下面一行(Run this Command)后复制对应的命令。
对于上图即:
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge完成之后,我们在Anaconda Powershell prompt 窗口中复制上述命令。
再接着输入y。等待即可安装成功。
(速度慢、失败见踩坑记录)
2.4 验证环境安装
关闭Anaconda Powershell prompt,再重新打开,再次通过命令conda activate pytorch 进入pytorch环境。
依次输入:
python 
import torch
torch.cuda.is_available()
可见,返回Ture,说明cuda安装成功,否则pytorch只能用cpu运行。
三,踩坑记录
3.1 上文2.1部分踩坑
这里如果产生类似报错:

请检查系统环境变量中,Path路径。所有的变量必须分条写,不能用“;”写在一条里。
3.2 上文2.3中遇到的安装失败、速度太慢等问题。
(1)看了很多博客建议用清华镜像,但是我试了很多遍都失败了。第一次很快的安装上了CPU版本的,导致电脑重装从头再来。这里还是建议就在官网下载,我是晚上放着,早上起来就装好了。多试几次。
(2) 安装的时候不要挂VPN,必然失败,或者报错。我因为这个浪费了一个下午。
(3)更新conda 命令。
3.3 torch.cuda.is_available()返回false可能的原因
(1)检查是否有GPU。
(2)检查CUDA以及CUDNN环境、系统Path变量配置。
(3)检查显卡驱动是不是最新的。
边栏推荐
- 剑指 Offer II 028. 展平多级双向链表
- Methods of strings in JS charat(), charcodeat(), fromcharcode(), concat(), indexof(), split(), slice(), substring()
- mysql导入导出数据到excel表日期出现问题
- Concat(), join(), reverse(), sort() method in JS array
- The editor is used every day. What is the working principle of language service protocol?
- 画图常用配色
- Koa 框架
- Why are databases cloud native?
- Matlab simulation of m-sequence
- (5) Pyqt5 ---- another method of connecting signals and slots
猜你喜欢

MySQL adds, modifies, and deletes table fields, field data types, and lengths (with various actual case statements)

出手即不凡,这很 Oracle!

2021-09-22

Using CMD (command prompt) to install MySQL & configure the environment

Draw the satellite sky map according to the azimuth and elevation of the satellite (QT Implementation)

2021-10-21

Command line garbled

架构师必备的七种能力

(2) Pyqt5 tutorial -- > using qtdesigner to separate interface code

Elemtnui select control combined with tree control to realize user-defined search method
随机推荐
[转]以终为始,详细分析高考志愿该怎么填
百度搜索稳定性问题分析的故事
2021-09-02
英语口语 - 连读
Laravel excel export
JS uses the for loop in the function to insert and delete the array at the specified position
Write regular isosceles triangle and inverse isosceles triangle with for loop in JS
Figure explanation of fiborache sequence
el-select clear 清空内容时触发事件
Possible problems when idea encounters errors occurred while compiling module (solved)
Matlab simulation of m-sequence
(4) Pyqt5 tutorial -- > Custom signal and slot (super winding...)
Parse JSON format data and save it to entity class
Resolution of PPT paper drawing
Koa 框架
Oral English - continuous reading
torch.tensor拼接与list(tensors)
Resolved: could not find artifact XXX
Ramda rejects objects with null and empty object values in the data
Common software numerical filtering methods (I) have been applied