How to install cuda version of pytorch on nvidia jetson nano

foreword

Yesterday afternoon, I got the jetson nano board because of work. I tried to install pytorch habitually, but found that something was wrong. After some torture, I finally installed it this morning. I would like to share my experience here, hoping that people will avoid detours later.
Let me say it first: If your nano is python3.6.9 (corresponding to jetpack 4.6), don't try to upgrade the python version. Nano only supports jetpack 4.6 at the highest.

how to install

Environment: jetson nano ubuntu18.04, jetpack4.6 has been flashed, and python3 is 3.6.9. It is
very simple to install the cpu version of torch, just enter the official website command on pytorch.
But if you want to use cuda, that is, the gpu version of torch, there are only two ways:
1. Compile the source code of pytorch yourself.
2. Download the pytorch wheel pre-compiled by NVIDIA or others.

Here we only talk about the second method:
Link 1 includes torch and torchvision
Link 2 only includes torch.
In addition, because the files are too large, they are all placed in Google Cloud Disk, so I won’t say much about how to access Google Cloud Disk.

When downloading, note that jetson nano can only be supported by 3.6python, that is, the highest supported version 1.10.0 of pytorch, and the version corresponding to torchvision is 0.11.0. why? Because of

Hi @m.ahmad4984, JetPack 5.0.2 is in the final preparations to be released, so it should be posted in the next few days pending any unforeseen delays or blockers.
As per the Jetson Software Roadmap 52, JetPack 4.6 was the last major release for Nano/TX1/TX2 and JetPack 5.x supports Xavier and Orin devices.

The official words mean that the highest jetpack version supported by nano is 4.6, which is python3.6.9, and the last version of torch that supports 3.6 is 1.10.0. If you are not nano but xavier or a more advanced model, then choose the version of python3.8.

Installation FAQ

1. After downloading the wheel, install it with pip3, if prompted:

“error:torch is not a supported wheel on this platform”

If you downloaded the pre-compiled version and this problem occurs, it is actually that your pip3 version is not compatible with your python3.6. This problem was left over when I tried to update python and pip before.

Solution:

wget https://bootstrap.pypa.io/get-pip.py
sudo python3.6 get-pip.py

That is, reinstall the corresponding version of pip.

2. Enter the python3 environment and try to import torch:

numpy.core.multiarray failed to import
或者
numpy illegal instruction (core dumped) jetson

It means that there is a problem with your numpy version, which is not compatible with torch!

Solution:
first uninstall all numpy, and then reinstall the lower version numpy:

#1.19.5出错
pip3 install numpy==1.19.4

Inspection after installation

Enter the following command to view:

import numpy
import torch
torch.__version__
torch.cuda.is_available()

If no exception is reported and torch.cuda.is_available displays True, it means that the installation is completed normally, as shown in the following figure:

insert image description here

Guess you like

Origin blog.csdn.net/weixin_43945848/article/details/127122522