PyTorch Install problem (Solved)

Thank you downloading and installing the whl worked for me!

Hi,

Here are the package for pyTorch on JetPack4.1.1:

python2.7
[url]https://drive.google.com/open?id=1F-P1w6s2s8teFxcy25rRFfie_9CAyLcX[/url]

python3.6
[url]https://drive.google.com/open?id=1yepdDCjqcoGARir9GqXAkpXkAyd6HASF[/url]

Thanks.

Thank you so much AastaLLL!

I tried to use the .whl to install PyTorch but I’m still running into issues. I just flashed my Jetson Xavier with JetPack-L4T-4.1.1-linux-x64_b57.run. I installed python3.6 with

sudo apt-get python3-pip

. I then downloaded the Python3.6 whl from comment #18 and ran

pip3 install torch-1.0.0a0+7a65461-cp36-cp36m-linux_aarch64.whl

which ran without any issues. Now when I start an instance of python and import torch, I get the following error:

python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/nvidia/.local/lib/python3.6/site-packages/torch/__init__.py", line 84, in <module>
    from torch._C import *
ImportError: libtorch.so.1: cannot open shared object file: No such file or directory

Any suggestions? Thank you!!

I ran into the same issue. Turns out that the CUDA toolkit was not installed correctly from Jetpack 4.1.1.
(/usr/local/cuda-10.0 was not installed after reflashing).

On the Xavier, I noticed apt-get was not working, so I did an update
> sudo apt-get update

Relaunch Jetpack 4.1.1, and just reinstall the target modules. Verify Cuda 10 is installed.

Install the pytorch

sudo pip3 install torch-1.0.0a0+8601b33-cp36-cp36m-linux_aarch64.whl
sudo pip3 install torchvision

if all works

python3

import torch
torch.backends.cudnn.is_acceptable(torch.cuda.FloatTensor(1))

How to add cuda10 patch

For what is worth, I’ve reverted to building pytorch from source as the wheel was not built with the settings I needed. I created a fork on github with the changes for the Xavier. By default it builds pytorch with TensorRT backend enabled, and expects OpenBLAS to be installed.

https://github.com/rtarquini/pytorch

-Rich

Nice! Thanks for sharing!

How to add cuda10 patch

I ran into the same issue.But my cuda10 was installed .what can I do?

Hi,

Are you using JetPack 4.2?

Please check this topic for the pyTorch package for the JetPack4.2:
[url]https://devtalk.nvidia.com/default/topic/1049071/pytorch-for-jetson-nano/[/url]

Thanks.

Thanks,I did it ,but it showed error:

Processing ./torch-1.1.0a0+b457266-cp36-cp36m-linux_aarch64.whl
ERROR: Exception:
Traceback (most recent call last):
File “/home/nvidia/.local/lib/python3.6/site-packages/pip/_internal/cli/base_command.py”, line 178, in main
status = self.run(options, args)
File “/home/nvidia/.local/lib/python3.6/site-packages/pip/_internal/commands/install.py”, line 352, in run
resolver.resolve(requirement_set)
File “/home/nvidia/.local/lib/python3.6/site-packages/pip/_internal/resolve.py”, line 131, in resolve
self._resolve_one(requirement_set, req)
File “/home/nvidia/.local/lib/python3.6/site-packages/pip/_internal/resolve.py”, line 294, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File “/home/nvidia/.local/lib/python3.6/site-packages/pip/_internal/resolve.py”, line 242, in _get_abstract_dist_for
self.require_hashes
File “/home/nvidia/.local/lib/python3.6/site-packages/pip/_internal/operations/prepare.py”, line 353, in prepare_linked_requirement
progress_bar=self.progress_bar
File “/home/nvidia/.local/lib/python3.6/site-packages/pip/_internal/download.py”, line 873, in unpack_url
unpack_file_url(link, location, download_dir, hashes=hashes)
File “/home/nvidia/.local/lib/python3.6/site-packages/pip/_internal/download.py”, line 807, in unpack_file_url
unpack_file(from_path, location, content_type, link)
File “/home/nvidia/.local/lib/python3.6/site-packages/pip/_internal/utils/misc.py”, line 628, in unpack_file
flatten=not filename.endswith(‘.whl’)
File “/home/nvidia/.local/lib/python3.6/site-packages/pip/_internal/utils/misc.py”, line 505, in unzip_file
zip = zipfile.ZipFile(zipfp, allowZip64=True)
File “/usr/lib/python3.6/zipfile.py”, line 1131, in init
self._RealGetContents()
File “/usr/lib/python3.6/zipfile.py”, line 1198, in _RealGetContents
raise BadZipFile(“File is not a zip file”)
zipfile.BadZipFile: File is not a zip file

what can I do?

Hi,

Please noticed this wheel is for JetPack4.1.1.
If you want the version for JetPack 4.2, please check this topic:
[url]https://devtalk.nvidia.com/default/topic/1049071/jetson-nano/pytorch-for-jetson-nano/[/url]

Thanks.

thanks very much! You solved my problem

when I use the whl file in my python3.6, I get the following ERROR:
$sudo pip3 install torch-1.0.0a0+8601b33-cp36-cp36m-linux_aarch64.whl
WARNING: The directory ‘/home/dji/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
WARNING: The directory ‘/home/dji/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
Processing ./torch-1.0.0a0+8601b33-cp36-cp36m-linux_aarch64.whl
Installing collected packages: torch
Successfully installed torch-1.0.0a0+8601b33
$dji@manifold2:~/Downloads$ python3
Python 3.6.8 (default, Oct 9 2019, 14:04:01)
[GCC 5.4.0 20160609] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import torch
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python3.6/dist-packages/torch/init.py”, line 84, in
from torch._C import *
ImportError: libcudart.so.10.0: cannot open shared object file: No such file or directory
Error in sys.excepthook:
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/apport_python_hook.py”, line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File “/usr/lib/python3/dist-packages/apport/init.py”, line 5, in
from apport.report import Report
File “/usr/lib/python3/dist-packages/apport/report.py”, line 30, in
import apport.fileutils
File “/usr/lib/python3/dist-packages/apport/fileutils.py”, line 23, in
from apport.packaging_impl import impl as packaging
File “/usr/lib/python3/dist-packages/apport/packaging_impl.py”, line 23, in
import apt
File “/usr/lib/python3/dist-packages/apt/init.py”, line 23, in
import apt_pkg
ModuleNotFoundError: No module named ‘apt_pkg’

Original exception was:
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python3.6/dist-packages/torch/init.py”, line 84, in
from torch._C import *
ImportError: libcudart.so.10.0: cannot open shared object file: No such file or directory

xception:
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/pip/basecommand.py”, lin
status = self.run(options, args)
File “/usr/lib/python3/dist-packages/pip/commands/install.py”
with self._build_session(options) as session:
File “/usr/lib/python3/dist-packages/pip/basecommand.py”, lin
if options.cache_dir else None
File “/usr/lib/python3.6/posixpath.py”, line 80, in join
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not int

when i am trying use pip3 to install torvision ,i always met this question,who can help me ?

Hi @530869411, instead of using pip3 to install torchvision, on Jetson you should build it from source as shown under the ‘Installation’ section of this post: PyTorch for Jetson

1 Like

Thank you