Pytorch only works in the pytorch directory

After installing pytorch from source, along with CUDA and CUDNN, I am only able to successfully import torch from the pytorch directory, so know that the installation has all of the required modules.

However, In any other directory, I get an error:

import torch
Traceback (most recent call last):
File “”, line 1, in
File “/home/tom/.virtualenvs/vm4ml/lib/python3.7/site-packages/torch/init.py”, line 267, in
_C._initExtension(manager_path())
AttributeError: module ‘torch’ has no attribute ‘QUInt4x2Storage’

How to approach this problem?

I have same issue too.
One virtual env have no problem to run torch, but another have same issue.

python==3.7
torch==1.7.1

Error:

import torch
Traceback (most recent call last):
File “”, line 1, in
File “/home/ubuntu/anaconda3/envs/koBART-trans/lib/python3.7/site-packages/torch/init.py”, line 500, in
_C._initExtension(manager_path())
AttributeError: module ‘torch’ has no attribute ‘QUInt4x2Storage’