No module named ‘torch’ but I installed

I trying to use trt_pose and following githabpage “Getting started Step1.1” I downloaded “pytorch” and “torchvision”.
I tested it according to this page and it seemed to work properly.

The text below is the result of the test
$ python3
Python 3.8.10 (default, May 26 2023, 14:05:08)
[GCC 9.4.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import torch >>> print(torch.version)
>>> print('CUDA available: ' + str(torch.cuda.is_available())) CUDA available: True >>> print('cuDNN version: ’ + str(torch.backends.cudnn.version()))
cuDNN version: 8600
>>> a = torch.cuda.FloatTensor(2).zero_() >>> print('Tensor a = ’ + str(a))
Tensor a = tensor([0., 0.], device=‘cuda:0’)
>>> b = torch.randn(2).cuda() >>> print('Tensor b = ’ + str(b))
Tensor b = tensor([-1.0415, -0.2904], device=‘cuda:0’)
>>> c = a + b >>> print('Tensor c = ’ + str(c))
Tensor c = tensor([-1.0415, -0.2904], device=‘cuda:0’)
>>> import torchvision Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'torchvision' >>>
[2]+ Stopped python3

But I try “sudo python3 install --plugins”

Traceback (most recent call last):
File “”, line 3, in
import torch
ModuleNotFoundError: No module named ‘torch’

why doesn’t it recognize pytorch?


It looks like you can find PyTorch with python3 but cannot find it with sudo python3.
Could you help to confirm it?


you were right.
I can find PyTorch with python3 but cannot find it with sudo python3.
How I fix this?
May be it has something to do with me using a venv virtual environment?

I realized that Ihad made a big mistake.
My problem is In venv virtual environment, can’t import tensorrt regardless of sudo


Have you solved the issue?

yes.The issue was resolved by simply adding the pythonpath. thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.