pytorch深度学习环境配置

安装anaconda3,检查各模块是否能正常使用,点击enviroment ,从all中搜索pypi进行安装pyinstall
打开anaconda prompt,输入命令行:conda create -n pytorch python=你的python版本,例如,我的是3.8,则python=3.8
base环境下添加以下清华镜像源下载通道
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123/
 

若以上通道添加均不行,可在https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/此网站查询下载,或搜索相应的包,一定要对应到自己选择的cuda版本
打开pytorch,输入:conda activate pytorch
输入命令行:conda install pytorch torchvision cudatoolkit=cuda版本,,,,自行查阅https://pytorch.org/
等待安装即可

若存在下载文件中断被跳过,可反复使用命令行:::conda install pytorch torchvision cudatoolkit=cuda版本,直至完全安装,但此时会出现warning报错
可根据错误指示内容,在以下路径中C:\Users\“Usename”\.conda\pkgs删除相应文件。

检测pytorch是否安装成功,输入命令行pip list即可查询
或输入命令行在pytorch环境下输入

python

其次再输入命令行
import torch
 torch.cuda.is_available()
若显示为True,即为正确安装
安装jupyter notebook
打开pytorch:conda activate pytorch
输入命令行:conda install jupyter notebook
等待安装,若出现安装跳过,可参考之前的方法,反复输入命令行:conda install jupyter notebook
再根据相应错误提示,删除相应文件
若安装完毕
在pytorch环境下输入:jupyter notebook
new,新建python,输入以下命令行
import torch

print(torch.__version__)
print(torch.cuda.is_available())
运行结果为torch版本和true即表示成功安装


出现以下错误,表示自身网速不行,需更换WLAN连接。或者在清华镜像源下载相应的包,拖到C:\Users\“Usename”\.conda\pkgs中,,,,Username为你的用户名,一切命名必须是英文
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-64/pywin32-300-py38h294d835_0.tar.bz2>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/icu-58.2-ha925a31_3.conda>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值