之前安装过pytorch,但是显示cuda不可用,一气之下卸载了pytorch,结果就是一直报错。

显示的错误: ERROR: Exception: Traceback (most recent call last): File "D:\Anacoda\lib\si.........后面吧啦吧啦一堆。

最终解决的方法再下面做个记录。

安装清华源,(都能搜到怎么操作)

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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes

进入pytorch官网,选择合适的版本。

官网链接在这:PyTorch

复制上面的下载命令。

接着打开anaconda powershell prompt

将命令行输入进去,后面加

-f https://download.pytorch.org/whl/torch_stable.html

有的博主说要删掉-f后面的东西再加上面这段,我也试了,但都报错,最后我试了一把,没有删掉的这个,结果成功了!

最终测试如下!

 now the new:pip install torch==2.0.0+cu118 torchvision==0.15.1+cu118 torchaudio==2.0.1+cu118 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐