Win10搭建Pytorch环境

1. 查看硬件: 主要是显卡型号,确认已装显卡驱动 。使用nvdia-smi查看支持的最高版本cuda toolkit.
2. 安装cuda toolkit 
3. 安装cudnn,将cudnn中的 bin include lib 在c-program files-GPU进行替换。
4. 安装anaconda;
5. 安装pycharm;

6.安装常用安装包https://www.cnblogs.com/yhlx125/p/18155080。

使用pip list 查看已安装完成的包。

----------------------------------------------------------------------------------------------------------------

https://pytorch.org/

https://blog.csdn.net/weixin_43737866/article/details/127784768

https://www.jianshu.com/p/4c7b9127cf83

https://blog.csdn.net/m0_56945481/article/details/126998629

1. 先检查显卡驱动版本,在cmd里输入nvidia-smi即可查看,结果如下:

显卡支持的CUDA最高版本为12.0,下载10.2版本,后面采样11.3版本

CUDA Toolkit 11.7 Update 1 Downloads | NVIDIA Developer

下载的安装包名称:cuda_10.2.89_441.22_win10.exe

 

第一次装Anaconda3最新版,报Solving environment: failed with initial frozen solve. Retrying with flexible solve.

搞了这个命令

conda config --add channels conda-forge
conda config --set channel_priority flexible

之后,更新conda,完了之后报错ImportError: DLL load failed while importing _ctypes: 找不到指定的模块。

1.于是重装Anaconda3-5.3.1-Windows-x86_64

(base) C:\Users\yhexie>conda info

CustomValidationError: Parameter channel_priority = 'flexible' declared in C:\Users\yhexie\.condarc is invalid.
The value 'flexible' cannot be boolified.

2.删除C:\Users\yhexie\.condarc,重新启动。

https://blog.csdn.net/xu96944967/article/details/127595899

3.conda安装的居然没有cuda支持,然后换一个虚拟环境继续装

pip install numpy==1.16.2 (安装最新版本1.25.1,pycharm编译报错)

pip install torch==1.10.1+cu102 torchvision==0.11.2+cu102 torchaudio==0.10.1 --extra-index-url https://download.pytorch.org/whl/cu102

这个命令跑了2遍,成功了。

检查:

import torch

print(torch.__version__) #查看pytorch版本

print(torch.cuda.is_available()) #查看cuda是否可用 输出为True 或者False

 

(利用conda命令总是不成功,也可以尝试使用pip命令进行安装,这时就需要将镜像源改成pip的镜像源;同时如果conda命令和pip命令都不行,也可以利用先下载whl文件,然后pip直接安装的方法。)

 

posted @ 2023-08-29 22:41  太一吾鱼水  阅读(103)  评论(0编辑  收藏  举报