PyTorch for Jetson

OK thanks, I updated the pip3 install instructions to include numpy in case other users have this issue.

1 Like

from china
burn in jetson-nano-sd-r32.1-2019-03-18.img today.
download torch-1.1.0a0+b457266-cp36-cp36m-linux_aarch64.whl

-bash: pip3: command not found

do I need to install pip3?

sudo apt-get update failed.

python3-pip or python3-dev can’t be located.

edit /etc/apt/source.list to Chinese images failed again.

help!

Hi huhai, if apt-get update failed, that would prevent you from installing more packages from Ubuntu repo. Are you behind a firewall that is preventing you from connecting to the Ubuntu package repositories?

pip3 installed using:
https://bootstrap.pypa.io/get-pip.py
referencing :
https://packaging.python.org/tutorials/installing-packages/#ensure-you-can-run-pip-from-the-command-line

pip3 install numpy stlll failed.

restored /etc/apt/sources.list
apt-get work fine. Its the network , should be.
reinstalled pip3

numpy installed ok using:
pip3 install numpy --user

Playing ubuntu 16.04 and pytorch on this network for a while already, apt-get works well before.

New to ubuntu 18.04 and arm port, will keep working on apt-get .

turn out the wheel file can’t be download from china.
the file downloaded before have zero byte.
using an aliyun esc in usa finished the download job.

finally pytorch installed.

torch.cuda.is_available()
True

PS: compiling pytorch using jetson nano is a nightmare .

@dusty_nv ,
Hi, could you tell me how to install torchvision?
I cant install it by “pip3 install torchvision” cause it would collecting torch(from torchvision), and PyTorch does not currently provide packages for PyPI.

Please help me out. Thanks a lot

Hi buptwlr, run the commands below to install torchvision. It is installed from source:

$ git clone https://github.com/pytorch/vision
$ cd vision
$ sudo python setup.py install
2 Likes

When installing torchvision, I found I needed to install libjpeg-dev (using sudo apt-get install libjpeg-dev) becaue it’s required by Pillow which in turn is required by torchvision.

1 Like

Hi,
I’m getting a weird error while importing. I installed using the pre-built wheel specified in the top post.

>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/nvidia/python3/lib/python3.6/site-packages/torch/__init__.py", line 97, in <module>
    from torch._C import *
ImportError: libcusparse.so.10.0: cannot open shared object file: No such file or directory

I’m using a Xavier with the following CUDA version.

>>> cat /usr/local/cuda-10.0/version.txt 
CUDA Version 10.0.117
2 Likes

Hi haranbolt, have you re-flashed your Xavier with JetPack 4.2? Are you able to find cusparse library?

I had flashed it using JetPack 4.1.1 Developer preview. Is it necessary to reflash it using JetPack 4.2?

Yes, these PyTorch pip wheels were built against JetPack 4.2.

@dusty_nv
I am trying to build the pytorch on jetson nano.when I try to download the wget link (wget https://nvidia.box.com/shared/static/veo87trfaawj5pfwuqvhl6mzc5b55fbj.whl -O torch-1.1.0a0+b457266-cp36-cp36m-linux_aarch64.whl) you have posted, but it occurs connection refused. could you share a google drive link or other available link. thank you.

Hi Perry, what happens if you try http://nvidia.box.com/shared/static/veo87trfaawj5pfwuqvhl6mzc5b55fbj.whl (without HTTPS)?

If that doesn’t work either, I will put it on Google Drive for you.

thank you for quick reply @dusty_nv.
this link is still unable to resolve. please put it on Google Drive, thx!

I have a faster-rcnn.pytorch model. The repository address for this project is: https://github.com/jwyang/faster-rcnn.pytorch. I want to port this model to jetson nano. Is there a tutorial for reference? .

The jetson I bought has already installed python 3.6 and JetPack 4.2, so I didn’t build any wheels according to “Build Instructions”.
I downloaded the swap partition just by following “Build Instructions”.
I downloaded the “torch-1.1.0a0+b457266-cp36-cp36m-linux_aarch64.whl” offline, and then used “pip3 install .whl” to install pytorch1.1. I also used the following command to the torchvision:
$ git clone GitHub - pytorch/vision: Datasets, Transforms and Models specific to Computer Vision
$ cd vision
$ sudo python setup.py install

But when I install scipy with “pip3 install scipy” it always fails.

Any help will be greatly appreciated.

zcy@zcy-desktop:~/0_projects/faster-rcnn.pytorch$ pip install Cython
Collecting Cython
  Downloading https://files.pythonhosted.org/packages/f8/da/c979464858b257b21a6472a85285548c91f5b4dc773cb049cfdfb3ceeb02/Cython-0.29.7.tar.gz (2.0MB)
    100% |████████████████████████████████| 2.0MB 45kB/s 
Building wheels for collected packages: Cython
  Building wheel for Cython (setup.py) ... done
  Stored in directory: /home/zcy/.cache/pip/wheels/79/b9/15/c589b51f4e91b37faa76362180166a2041e4286c38dbc45fc6
Successfully built Cython
Installing collected packages: Cython
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/dist-packages/cython.py'
Consider using the `--user` option or check the permissions.

Hi zcy, did you try installing this package with the --user flag to pip? And if that doesn’t work, by running pip with sudo permissions?

@zcy I’m having trouble installing scipy as well. Here is a thread about it https://devtalk.nvidia.com/default/topic/1049426/jetson-nano/using-pip3-pip-to-install-scipy-will-be-stuck/ .

thanks, it`s work.
By the way, is there an example of porting the pytorch model to jetson nano ?

Hi dusty, could you post the checksum for the wheel file (https://nvidia.box.com/shared/static/veo87trfaawj5pfwuqvhl6mzc5b55fbj.whl)? I download it multiple times and it’s still broken. (Got zipfile.BadZipFile: File is not a zip file error message).

1 Like