Search code examples
pytorchtorch

How to fix 'cannot initialize type TensorProto DataType' error while importing torch?


I installed pytorch using pip3 command for my windows pc without GPU support. But when I tried to import torch it is giving an error.

At first, there was a different error saying numpy version not matching and I updated the numpy to the latest version.

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

Solution

  • I reinstalled anaconda and then created a virtual environment for pytorch.Now everything works fine