操作系统:win10;
已安装anaconda;
1、创建pytorch虚拟环境:
输入命令:
conda create -n pytorch python=3.9
创建完成:
===========================================================
注:该过程可能出现的问题:
由于我之前修改过下载源这里出现报错:
UnavailableInvalidChannel: The channel is not accessible or is in...
在此可以通过命令查看channel的信息:
conda config --show
移除报错的channel:
conda config --remove channels http://xxxxxxx(上一步的channels地址)
现在查看channel只剩下defaults。
==================================================================
2、激活pytorch环境:
conda activate pytorch
此时已由base环境切换到pytorch环境下
查看已安装的包:
pip list
3、安装pytorch
若驱动不是最新,可去英伟达官网找到自己对应显卡驱动更新::官方驱动 | NVIDIA下载适用于 GeForce、TITAN、NVIDIA RTX、数据中心、GRID 等 NVIDIA 产品的新驱动。https://www.nvidia.cn/Download/index.aspx?lang=cn查看显卡驱动(英伟达显卡);
nvidia-smi
pytorch官网:
https://pytorch.org/
cuda10.2版本官网没有提供安装命令,我更新驱动后cuda version为11.7,所以直接选11.3版本,10.2安装方式没去研究了,如有大佬安装10.2可以艾特我一下教程。
复制以上命令回到pytorch环境:
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
接下来就是漫长的等待下载过程......
完成后输入pip list看看安装的包,我们看到torch1.12版本已经安装
接下来继续验证pytorch是否能正常使用gpu:
依次输入:
python
>>>import torch
>>>torch.cuda.is_available()
当看到True表示可以正常使用。
至此,pytorch完成安装。
完结撒花!