'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 1:[1]

If you are running this in colab, remember to restart your runtime after installing your modules with pip.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ItCameFr0mMars