人工智能环境搭建anaconda+pytorch(windows下)

目录

 

1 官网下载windows版本anaconda

2 安装到D盘下

3 开始,选择anaconda文件下的指令界面

4 创建环境

5 激活环境

6 添加镜像

7 安装显卡驱动

8 安装PyTorch

9 查看版本,测试使用环境


 

1 官网下载windows版本anaconda

最新版本是python3.9,为了稳定一点,下了旧版本

官网底部找旧版本网址

3304cfb848ef416f9251edd08097336f.png

 

旧版本:Index of /

 46628c58c90e43849bf2af58b7e5cb13.png

 

2 安装到D盘下

3 开始,选择anaconda文件下的指令界面

4 创建环境

conda create -n py37 python=3.7
y

 

5 激活环境

conda activate py37

//查看文件
conda list

 

 

6 添加镜像

查看已有的源

conda config --show channels
# 添加清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
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/pytorch/
 
# 添加阿里云镜像源
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/free/
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/main/
 
# 添加中科大源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/


设置搜索时显示通道地址

conda config --set show_channel_urls yes 

 

如果下载还是慢的话,去掉默认源

conda config --remove channels defaults

 

7 安装显卡驱动

 

参考这篇文章

安装cuda驱动_2小溪的博客-CSDN博客

 

8 安装PyTorch

7364dce3c2a74c799a360156d29c3081.png

旧版地址

Previous PyTorch Versions | PyTorch

 避坑警告!高能预警!

由于安装时报错,各种包冲突,所以最终选择 pytorch1.12.1的版本

这里不要用镜像下载,因为镜像下载的pytorch还是cpu版本的,最后测试的时候,cuda还是用不了,所以一定要用官方给的地址下!

 

conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge

2164d9fe816b42109264a70ef7b15d56.png

 

查看环境

conda info -e

be206d7055c8416fb55fccb6d58d03a5.png

 

9 查看版本,测试使用环境

python

import torch

torch.cuda.is_available()  // true,证明cuda功能可以正常使用

quit()

conda deactivate

299fb804947d4153ac6451ce3a529686.png

啊啊啊啊啊啊啊啊

折磨了两天各种重启和重装,终于搞定了啊啊啊啊啊!!!!!!!!

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值