在安装pytorch时候可能会有很多困难,版本对应就是一个问题
首先先装好了anaconda,这里可以直接在官网下载anaconda
然后装的cuda是11.7版本,如何查看cuda版本,在cmd内输入以下命令
nvidia-smi
接着去pytorch官网,去pytorch官网找到对应版本的pytorch
我这里直接选择对应的是cuda11.6,目前是没有发现影响,如果怕后面出现问题的话可以去下载cuda11.6版本
将NOTE下面的命令复制出来,就是这样
conda install pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge
先不要急着运行命令,如果直接用pytorch官网去下载可能会非常缓慢卡住,先导入清华镜像源,每一行都运行一次
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/pytorch/
再将刚才复制的命令里的 -c pytorch删除,输入即可(这个安装命令需要用管理员身份启动cmd,否则会提示权限不足)
conda install pytorch torchvision torchaudio cudatoolkit=11.6 -c conda-forge
最后验证是否下载成功
在conda的环境中运行
如果显示True的话,说明安装成功