Why my torchvision only works with sudo python3.
I am working on Jetson Nano B01 board. I follow the above instruction to install PyTorch 1.8.0. The only difference is that when I run pip3 install numpy torch-1.8.0-cp36-cp36m-linux_aarch64.whl
and python3 setup.py install --user
, sudo
is needed. otherwise
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 360, in run
prefix=options.prefix_path,
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 247, in move_wheel_files
prefix=prefix,
File "/usr/lib/python3/dist-packages/pip/locations.py", line 153, in distutils_scheme
i.finalize_options()
File "/usr/share/python-wheels/setuptools-39.0.1-py2.py3-none-any.whl/setuptools/command/install.py", line 38, in finalize_options
orig.install.finalize_options(self)
File "/usr/lib/python3.6/distutils/command/install.py", line 351, in finalize_options
self.create_home_path()
File "/usr/lib/python3.6/distutils/command/install.py", line 581, in create_home_path
os.makedirs(path, 0o700)
File "/usr/lib/python3.6/os.py", line 210, in makedirs
makedirs(head, mode, exist_ok)
File "/usr/lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/home/xinqifan2/.local/lib/python3.6'
After running the above command with sudo for pytorch and torchvision installation. Then, at the verification time. I can import pytorch without sudo, but if I do it for torchvision, it does not work. See below
xinqifan2@xinqifan2-desktop:~$ python3
Python 3.6.9 (default, Jan 26 2021, 15:33:00)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.__version__)
1.8.0
>>> print('CUDA available: ' + str(torch.cuda.is_available()))
CUDA available: True
>>> print('cuDNN version: ' + str(torch.backends.cudnn.version()))
cuDNN version: 8201
>>> 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.2091, 0.6310], device='cuda:0')
>>> c = a + b
>>> print('Tensor c = ' + str(c))
Tensor c = tensor([-1.2091, 0.6310], device='cuda:0')
>>> import torchvision
>>> print(torchvision.__version__)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'torchvision' has no attribute '__version__'
However, if I do this with sudo python3
, it works
xinqifan2@xinqifan2-desktop:~$ sudo python3
[sudo] password for xinqifan2:
Python 3.6.9 (default, Jan 26 2021, 15:33:00)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchvision
>>> print(torchvision.__version__)
0.9.0a0+01dfa8e
>>> import torch
>>> print(torch.__version__)
1.8.0
>>> print('CUDA available: ' + str(torch.cuda.is_available()))
CUDA available: True
What happened with my python or any packages? Why sudo is needed?