PyTorch for Jetson

Hi @nils, was there a more detailed compiler error, or is above all the error text that was output? It seems like the build stopped or was killed. You might want to try mounting swap memory and make sure you have enough disk space. You can keep an eye on tegrastats/jtop or look for out-of-memory messages in dmesg log.

I personally haven’t tried building under Python 3.8 or virtualenv, so unsure if that is related or not.

Hi @dusty_nv, thanks for your reply! I found out that by cloning the pytorch repo from GitHub, I received the 1.7.0a1 version. I have now pinned it to 1.6.0 and I am now building this version. Fingers crossed!

Hi,

My Jetson nano device runs JetPack 4.3, therefore, I downloaded
torch-1.4.0-cp36-cp36m-linux_aarch64.whl.
then I modified the installation code to
wget https://nvidia.box.com/shared/static/ncgzus5o23uck9i5oth2n8n06k340l6k.whl -O https://nvidia.box.com/shared/static/ncgzus5o23uck9i5oth2n8n06k340l6k.whl

is this right?
when I run the code in the terminal, I get an error message, like, “no such file or directory”.

Even if I just copy the same line as in the instructions, I get the same error.

Best regards,
Afshin

Hi @afsamani, that is the correct URL and wheel to be using for JetPack 4.3. Can you run these commands?

wget https://nvidia.box.com/shared/static/ncgzus5o23uck9i5oth2n8n06k340l6k.whl -O torch-1.4.0-cp36-cp36m-linux_aarch64.whl
sudo apt-get install python3-pip libopenblas-base libopenmpi-dev 
pip3 install Cython
pip3 install numpy torch-1.4.0-cp36-cp36m-linux_aarch64.whl

Hi again,
Thanks for your hints.
I realized that I made a mistake as I must have chosen python 2.7 instead. After realizing this mistake, wget command runs successfully but I still get an error in the pip install line. I tried with both 1.4 and 1.3 versions and both of them gave me the same error message “ERROR: torch-1.3.0-cp27-cp27mu-linux_aarch64.whl is not a supported wheel on this platform.”

I run the following lines:

wget https://nvidia.box.com/shared/static/6t52xry4x2i634h1cfqvc9oaoqfzrcnq.whl -O torch-1.3.0-cp27-cp27mu-linux_aarch64.whl

sudo apt-get install libopenblas-base libopenmpi-dev

pip install future torch-1.3.0-cp27-cp27mu-linux_aarch64.whl

Any other suggestion?

Thanks a lot again.

Best,
Afshin

Hmm, is it possible that your pip is symbolically linked to pip3? What does running pip --version show you?

For testing, are you able to install the python3/pip3 PyTorch wheel without the error?

thanks again,

pip version: pip 19.3.1
python version: Python 2.7.17

the error message come with a few more warnings so I paste them here too.

WARNING: The directory ‘/home/dlinano/.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/dlinano/.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.
ERROR: torch-1.3.0-cp27-cp27mu-linux_aarch64.whl is not a supported wheel on this platform.
WARNING: You are using pip version 19.3.1; however, version 20.2.3 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.

I also tried the following command:

pip3 install pytorch

I faced with the following warning and error messages
WARNING: The directory ‘/home/dlinano/.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/dlinano/.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.
Collecting pytorch
Downloading https://files.pythonhosted.org/packages/ee/67/f403d4ae6e9cd74b546ee88cccdb29b8415a9c1b3d80aebeb20c9ea91d96/pytorch-1.0.2.tar.gz
Building wheels for collected packages: pytorch
WARNING: Building wheel for pytorch failed: [Errno 13] Permission denied: ‘/home/dlinano/.cache/pip/wheels/df’
Failed to build pytorch
Installing collected packages: pytorch
Running setup.py install for pytorch … error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-zin_95cp/pytorch/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-zin_95cp/pytorch/setup.py’“'”‘;f=getattr(tokenize, ‘"’“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’“‘))’ install --record /tmp/pip-record-ug3x0o5w/install-record.txt --single-version-externally-managed --compile
cwd: /tmp/pip-install-zin_95cp/pytorch/
Complete output (5 lines):
Traceback (most recent call last):
File “”, line 1, in
File “/tmp/pip-install-zin_95cp/pytorch/setup.py”, line 11, in
raise Exception(message)
Exception: You tried to install “pytorch”. The package named for PyTorch is “torch”
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '”‘"’/tmp/pip-install-zin_95cp/pytorch/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-zin_95cp/pytorch/setup.py’“'”‘;f=getattr(tokenize, ‘"’“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ install --record /tmp/pip-record-ug3x0o5w/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
WARNING: You are using pip version 19.3.1; however, version 20.2.3 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.

Can you try this for python3 install?

wget https://nvidia.box.com/shared/static/phqe92v26cbhqjohwtvxorrwnmrnfx1o.whl -O torch-1.3.0-cp36-cp36m-linux_aarch64.whl
sudo apt-get install python3-pip libopenblas-base libopenmpi-dev 
pip3 install Cython
pip3 install numpy torch-1.3.0-cp36-cp36m-linux_aarch64.whl

Hi again,

when I run:
pip3 install Cython

I get the following error.

BR
Afshin

WARNING: The directory ‘/home/dlinano/.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/dlinano/.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.
Collecting Cython
Downloading https://files.pythonhosted.org/packages/ad/4b/9e53bcce3c959fd0db143626e573210bba07be810fe8d7296373948c4183/Cython-0.29.21-py2.py3-none-any.whl (974kB)
|████████████████████████████████| 983kB 654kB/s
Installing collected packages: Cython
ERROR: 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.

WARNING: You are using pip version 19.3.1; however, version 20.2.3 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.

it seems to be a permission issue
try
sudo chown -R dlinano /home/dlinano
pip3 install Cython

Hi,

thanks for the hint. but I still get the same error:

ERROR: 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.

For your information, before getting this error message, I also got some warning about “Failed to establish a new connection”

I have borrowed the jetson nano from our university so it could very well be that I do not have all the administrative permissions.

Best regards,
Afshin

If you have sudo permissions, can you try sudo pip3 install Cython ?

If that works, run the other pip3 commands with sudo, too. If you continue having trouble, you might want to get a fresh SD card and re-flash with the latest JetPack release to rule out any issues with your environment.

Hi,

I install the .whl package

But I met the error “Segmentation fault (core dumped)”, when I “import torch”

How could solve this error?

Hi @xushoushuai, which version of JetPack-L4T are you on (please post the results of cat /etc/nv_tegra_release command), and which PyTorch wheel/URL did you install?

You should download a PyTorch wheel for your version of JetPack-L4T from the first post in this topic.

Thank you so much for this, its is very educational and well documented

1 Like

nvidia@nvidia-desktop:~/Downloads/torchvision$ sudo python3 setup.py install
Traceback (most recent call last):
File “setup.py”, line 13, in
import torch
File “/home/nvidia/.local/lib/python3.6/site-packages/torch/init.py”, line 135, in
_load_global_deps()
File “/home/nvidia/.local/lib/python3.6/site-packages/torch/init.py”, line 93, in _load_global_deps
ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
File “/usr/lib/python3.6/ctypes/init.py”, line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: libcudart.so.10.2: cannot open shared object file: No such file or directory
nvidia@nvidia-desktop:~/Downloads/torchvision$ OSError: libcudart.so.10.2: cannot open shared object file: No such file or directory
-bash: OSError:: command not found

Hi @1013212763, what is the output if you run ls /usr/local ?

Which version of JetPack-L4T are you on (please post the results of cat /etc/nv_tegra_release command), and which PyTorch wheel/URL did you install?

You should pick a PyTorch wheel that matches your JetPack-L4T version.

ls /usr/local:bin cuda cuda-10.0 etc games include jetson_stats lib man sbin share src

R32 (release), REVISION: 3.1, GCID: 18186506, BOARD: t186ref, EABI: aarch64, DATE: Tue Dec 10 07:03:07 UTC 2019

I use Jetpack 4.3 l4t 32.3.1 CUDA 10.0.326 cuDNN 7.6.3.28
torch-1.5.0-cp36-cp36m-linux_aarch64.whl
Because I couldn’t open the WHL download link in China, I found a torch-1.5.0-cp36-cp36m-linux_aarch64.whl from the Internet was successfully installed, but the above problems were encountered during the installation of torchvision 0.6.0
.

OK, for JetPack 4.3, use one of these links:

JetPack 4.2 / 4.3

If you cannot access those links, here is a mirror on Google Drive: https://drive.google.com/drive/folders/11kXyMOlgLDrFWn0_UwsEnARqvild5woB?usp=sharing

Before you try installing this PyTorch wheel for JetPack 4.3, uninstall the previous one:

$ pip3 uninstall torch
$ sudo pip3 uninstall torch

Hi all, yesterday PyTorch v1.7.0 was released by the PyTorch maintainers. Here is the wheel for JetPack 4.4 / JetPack 4.4.1: