PyTorch for Jetson

You would need to re-build PyTorch from source (instructions are in the original post of this topic).

Soon after you start the build, make sure that it lists MAGMA as detected so you don’t go through the trouble of re-building if it didn’t actually detect it.

Using Jetpack 4.4
But torch::cuda::cudnn_is_available() is showing false.

Have you sloved this problem? I met this problem too but i do not know how deal with it.

Hi,man! I have solved this problem. It depends on libopenblas-dev. so, you could deal with it by running “sudo apt-get install libopenblas-dev”
Hope that can help you.

Will you also push up the PyTorch 1.6.0 Dockerfile to the repo?

Hi @jacob4, yes it is at jetson-containers repo, see the build script for how it is configured:

I have ran these two commands and the CUDA support for Pytorch has gone.

sudo apt remove --autoremove nvidia-cuda-toolkit
sudo apt remove --autoremove nvidia-*

How do I build PyTorch in a way that the CUDA support is restored? Following the instructions above on Jetson Nano installs Pytorch 1.4 but running torch.cuda.is_available() still returns False.

@fenil does it work again if you re-install those apt packages? It probably removed the CUDA drivers and JetPack components like cuDNN. You may be able to re-install it all with sudo apt-get install nvidia-jetpack.

If it is still not working, you probably want to re-flash fresh SD card image.

Hi I followed the steps listed and managed to complete all the steps. However, at the verification step (listed below) I was not able to check the version of torchvision as it returns that torchvision do not have a version. I tried another way by cd-ing to my root and ran python3 but when I try to import torchvision, it was unable to locate torchvision. Is it a pathing issue or?

import torchvision
print(torchvision.version)

Hi @Blqe, I think you need to do print(torchvision.__version__)

Or does it fail to import torchvision all together? If you are using python3, when you install torchvision do sudo python3 setup.py install

Hey @dusty_nv,

Thanks for the reply. Yap it is a typo on my part, I did ran print(torchvision.version).

torchvision can be imported but the version cannot be printed out. I did sudo python3 setup.py install as well.

Below is what I encounter:
Python 3.6.9 (default, Jul 17 2020, 12:50:27)
[GCC 8.4.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import torch
print(torch.version)
1.6.0
import torchvision
print(torchvision.version)
Traceback (most recent call last):
File “”, line 1, in
AttributeError: module ‘torchvision’ has no attribute ‘version

The underscore does not seem to appear on the post but I did include them. Appreciate your help.

Hi @Blqe, the correct command is with the underscores, like below:

>>> import torchvision
>>> print(torchvision.__version__)
0.7.0a0+6631b74

Hi dusty_nv,

I am installing the pytorch 1.4 following the instructions, I am using Jetpack 4.4 on TX2, but when I ran this command ‘sudo apt-get install python3-pip libopenblas-base libopenmpi-dev’,
I always got an error,

Setting up nvidia-l4t-bootloader (32.4.3-20200803161246) …
3310-B01—1–cti/tx2/orbitty-mmcblk0p1
Starting bootloader post-install procedure.
ERROR. Procedure for bootloader update FAILED.
Cannot install package. Exiting…
dpkg: error processing package nvidia-l4t-bootloader (–configure):
installed nvidia-l4t-bootloader package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
nvidia-l4t-bootloader
E: Sub-process /usr/bin/dpkg returned an error code (1)

could you please help me out? Thanks a lot!

Hi Dusty,

Yap I did what you mentioned. However, the forum post do not seem to show the underscores. The error remains the same:

Traceback (most recent call last):
File “”, line 1, in
AttributeError: module ‘torchvision’ has no attribute ‘ version

Is the error due to a bad installation?

Hi @jiangwei.wang, it seems this error is unrelated to installing PyTorch pre-requisites. Instead it may be from using OTA update with a different carrier board - please see this post:

You may want to re-flash your device with ConnectTech’s BSP for the latest JetPack release.

Hmm, when you view the post, does it look different than below? (I have added the orange boxes for emphasis on the relevant version commands:

To get the versions, there should be two underscores before and two underscores after:

print(torch.__version__)
print(torchvision.__version__)

Does either of those work for you?

Hello,

What am I supposed to do?

Thank you.

@forumuser if you are after 0.6.0 then command should be

git clone --branch v0.6.0 https://github.com/pytorch/vision torchvision

Need to add v before 0.6.0

1 Like

There appears to be a BIG problem with the 1.6.0 PyTorch wheel - it installs the wrong version (1.4.0!) This was driving me nuts until I read the output after installation carefully:

$ pip3 install numpy torch-1.6.0-cp36-cp36m-linux_aarch64.whl
Collecting numpy
Processing ./torch-1.6.0-cp36-cp36m-linux_aarch64.whl
Installing collected packages: numpy, torch
Successfully installed numpy-1.19.2 torch-1.4.0

Notice how, even though I downloaded and installed the “1.6.0” wheel, pip reports that I have installed torch-1.4.0.

I have resorted to using the “release candidate” version of this wheel (PyTorch for JetPack 4.4 - L4T R32.4.3 in Jetson Xavier NX) which worked flawlessly. (I am running JetPack 4.4 on a Xavier NX)

Hi @stephen.buchanan, is this the link you are using to download the 1.6.0 wheel?

https://nvidia.box.com/shared/static/9eptse6jyly1ggt9axbja2yrmj6pbarc.whl

For me that does indeed install 1.6.0…

Is it possible that you had 1.4.0 previously installed on your system? You might want to try running pip3 uninstall torch and sudo pip3 uninstall torch first.