1. 問題描述:我是在VScode中使用jupyter拓展,遠程連接服務器。
2. torch版本:2.0
3. pytorch版本: 1.9.1
4. 問題原因:torch 2.0版本以后中沒有 ‘_six.py’ 文件
5. 如何查看torch中的py文件?
我是用的anaconda,torch中的py文件位置為:
/envs/環(huán)境名/lib/python版本號(比如:python3.8)/site-packages/torch
6. 解決辦法
(1)我第一開始試著把torch1.9中的’_six.py’文件復制到torch2.0中,發(fā)現(xiàn)還是不行(不知道為啥,有大佬能解釋一下嗎?)
然后我又重新裝了torch1.9.1,問題解決了!
步驟如下:文章來源:http://www.zghlxwxcb.cn/news/detail-504909.html
pip uninstall torch
pip install torch==1.9.1
Tips: 如果在步驟5中發(fā)現(xiàn)有’_six.py’文件,可以點擊重啟jupyter kernel即可解決。文章來源地址http://www.zghlxwxcb.cn/news/detail-504909.html
到了這里,關于Pytorch出現(xiàn)錯誤Attribute Error: module ‘torch‘ has no attribute ‘_six‘的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!