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

目录

1 官网下载windows版本anaconda

2 安装到D盘下

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

4 创建环境

5 激活环境

6 添加镜像

7 安装显卡驱动

8 安装PyTorch

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


1 官网下载windows版本anaconda

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

官网底部找旧版本网址

人工智能环境搭建anaconda+pytorch(windows下)_第1张图片

 

旧版本:Index of /

 人工智能环境搭建anaconda+pytorch(windows下)_第2张图片

 

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

人工智能环境搭建anaconda+pytorch(windows下)_第3张图片

旧版地址

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

人工智能环境搭建anaconda+pytorch(windows下)_第4张图片

 

查看环境

conda info -e

人工智能环境搭建anaconda+pytorch(windows下)_第5张图片

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

python

import torch

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

quit()

conda deactivate

啊啊啊啊啊啊啊啊

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

你可能感兴趣的:(pytorch,人工智能,windows,python,深度学习)