(解决)Key already registered with the same priority: GroupSpatialSoftmax
原因:重复安装卸载pytorch
上午在实验室电脑上跑了一下代码,发现训练一个epoch需要22~24s,在我的笔记本(RTX2060)上只需要2s,当时还在想,这就是1660ti吗,真是有够好笑呢。下午发现cuda.is_available()是False,合着是在cpu上跑的啊,然后就发现,我torch怎么是cpu版本的呢?卸了重下,噩梦就开始了。
一顿下载之后,print(torch.version),就出现了标题的问题,csdn上一搜,说是把pytorch卸载两遍再重下就好了,照做之后还是不行,而且发现torch卸载之后,print(torch.version)竟然不会报no module named ‘torch’,惊了,我都卸载了你跟哪找到的torch啊。。。。。
一晚上过去后,总算在这里https://discuss.pytorch.org/t/importerror-key-already-registered-with-the-same-priority/86271找到了解决方法。
其实就是我之前再安装torch的时候终止了,但是site-packages目录下还有torch这个文件夹,手动删除,再重新下载就解决了。
贴一下老哥的回答
I had the same problem.
I installed PyTorch following this command:
pip install torch==1.5.1+cpu torchvision==0.6.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
However, I noticed that my Python environment had a previous installation of PyTorch+CUDA which was later removed (uninstalled).
What I found is that the uninstalled task was not able to remove all the content (library files such as *.DLLs, etc.) from torch folder in the site-packages directory. I had to delete manually that folder. Aftewards, I installed again PyTorch (with the correct version for my environment: no CUDA), and it started to work fine.
Conclusion: This problem is due to existent library files in the torch folder due to previous installations. One needs to remove them manually before reinstall again the latest version of PyTorch.
Cheers!
我觉得这些什么anaconda,torch一点也不智能,我要傻瓜式的下载好吗,天天调试环境就得半天一天的,切~
|