记录Win10遇到的torch.cuda.is

记录Win10遇到的torch.cuda.is,第1张

记录Win10遇到的torch.cuda.is

本文电脑配置
Win10+Anaconda+CUDA10.1+cudnn7.6.5

我当时是在官网使用的以下命令

conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.1

在装PyTorch后运行遇到:

AssertionError: Torch not compiled with CUDA enabled

在网上找了一些解决方法:
1.升级显卡驱动;
2.升/降torch版本

但是都没有解决,最后我使用conda list后发现

pytorch                   1.10.0              py3.7_cpu_0

这说明我安装的本来就是cpu版本
结合其他博主的帖子,我猜想到时因为conda自动安装就是cpu版本,但是我在镜像网站中没有找到cudnn7.6版本的对应PyTorch,本人又比较懒,没有重新安装cudnn,所以在PyTorch继续看安装指令,我发现除了conda命令,还可以用pip的方式安装,所以我就用一下命令安装

pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

具体连接:PyTorch官网

然后测试

>>> import torch
>>>> print(torch.cuda.is_available())
True

成功安装gpu版本的PyTorch!

希望学习永远不晚,现在跟着沐神学习PyTorch,希望能科研顺利!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5680476.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存