PyCharm使用PyTorch时出现AssertionError Torch not compiled with CUDA enabled问题

刚刚接触PyTorch,使用终端跑项目文件时出现了如下问题

PS F:\实验项目\DCRN\DCRN-main> python main.py
...
...
...
AssertionError: Torch not compiled with CUDA enabled

考虑到已经配置到对应的虚拟环境,并且该环境下确实安装了对应版本的torch,故十分困惑,使用Python控制台进行测试如下

发现CUDA可以正常使用,在网上搜寻后发现类似情况,但是他的解决方法是在base环境再安装一遍torch,我直接痛苦面具,并且我十分确定已经在PyCharm配置了对应环境,因此干脆换了个运行思路

PyCharm使用PyTorch时出现AssertionError Torch not compiled with CUDA enabled问题_第1张图片
PyCharm使用PyTorch时出现AssertionError Torch not compiled with CUDA enabled问题_第2张图片
PyCharm使用PyTorch时出现AssertionError Torch not compiled with CUDA enabled问题_第3张图片

不再报错,运行成功,说明PyCharm确实是进入对应虚拟环境了,在终端运行会报错应该是因为终端依旧处于base环境并且好像也无法activate其他环境

你可能感兴趣的:(pytorch,python,pycharm)