导入火炬时如何修复 'cannot initialize type TensorProto DataType' 错误?
How to fix 'cannot initialize type TensorProto DataType' error while importing torch?
我在没有 GPU 支持的 windows 电脑上使用 pip3 命令安装了 pytorch。
但是当我尝试导入 torch 时出现错误。
起初,有一个不同的错误说 numpy 版本不匹配,我将 numpy 更新到最新版本。
import torch
RuntimeError Traceback (most recent call last)
<ipython-input-10-c031d3dd82fc> in <module>()
----> 1 import torch
C:\Users\iamuraptha\Anaconda3\lib\site-packages\torch\__init__.py in <module>()
82 pass
83
---> 84 from torch._C import *
85
86 __all__ += [name for name in dir(_C)
RuntimeError: generic_type: cannot initialize type "TensorProtoDataType": an object with that name is already defined
我重新安装了 anaconda,然后为 pytorch.Now 创建了一个虚拟环境,一切正常
如果你是 运行 在 colab 中,请记得在使用 pip 安装模块后重新启动运行时。
我在没有 GPU 支持的 windows 电脑上使用 pip3 命令安装了 pytorch。 但是当我尝试导入 torch 时出现错误。
起初,有一个不同的错误说 numpy 版本不匹配,我将 numpy 更新到最新版本。
import torch
RuntimeError Traceback (most recent call last)
<ipython-input-10-c031d3dd82fc> in <module>()
----> 1 import torch
C:\Users\iamuraptha\Anaconda3\lib\site-packages\torch\__init__.py in <module>()
82 pass
83
---> 84 from torch._C import *
85
86 __all__ += [name for name in dir(_C)
RuntimeError: generic_type: cannot initialize type "TensorProtoDataType": an object with that name is already defined
我重新安装了 anaconda,然后为 pytorch.Now 创建了一个虚拟环境,一切正常
如果你是 运行 在 colab 中,请记得在使用 pip 安装模块后重新启动运行时。