How to enable cuda with pytorch, running on a jetson nano 2gb device

Hi There,
Maybe somebody can help me out here. I´m stucked.

I have installed Ubuntu 20.04 on a Jetson Nano 2gb device
jetson linux driver packaged R32.7.4 have been installed.
When I run nvcc --version i got the following :

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Sun_Feb_28_22:34:44_PST_2021
Cuda compilation tools, release 10.2, V10.2.300
Build cuda_10.2_r440.TC440_70.29663091_0

Python 3.9.18 is installed. I have created a virtual environment where I install

python3 -m pip install torch torchvision torchaudio

when I then run in a python console :

import torch

it returns “False”

I have no clue how to make it use CUDA ?

How did you install 20.04? Did you apply the nvidia binaries to your run-time as per the flashing procedure?

@damgaarderik pip install torch just installs the CPU-only PyTorch wheels on PyPi, those were not built with CUDA enabled. See this thread below for PyTorch+CUDA wheels, although we provide them for the standard version of Python and CUDA that come with JetPack (and for JetPack 4, that’s Ubuntu 18.04 and Python 3.6)

For other versions of Python, you would need to rebuild PyTorch from source. Instructions are included in that thread, but again it’s tested in a normal JetPack environment and you may encounter issues building it in a non-standard environment.

Since you performed a custom upgrade of your device to Ubuntu 20.04, before proceeding I’d also recommend that you make sure CUDA is still functional for you (by running some samples from the CUDA Toolkit lik

After flashing the nano with the image

I followed this

to upgrade to ubuntu 20.04

@damgaarderik not sure if that way retains CUDA functionality / GPU acceleration, and wouldn’t be supported in the builds so you would need to compile PyTorch from source for your desired version of Python. I would test that the CUDA samples still work first.

Hi again,
It did retained the CUDA functionality although it dropped some path configurations. I established the Paths, then CUDA 10.2 was working on ubuntu 20.04 with python 3.8.10.

Tried to install python 3.9 but I was not able to resolve the dependency that Ubuntu20.04 have on 3.8.10, so I ended up with this version.

Regarding pyTorch for CUDA then this procedure helped me : Install PyTorch on Jetson Nano - Q-engineering

And it is working. I tried to compile later versions than 1.13 (pyTorch) and 0.14 (Vision) but failed to make them work.
So the whl (from the link) works, out of the box, and luckly I´m not using features (right now) which require eg. pyTorch 2.x…or later version of Python.

So it can run with Ubuntu 20.04, Python 3.8.10, PyTorch.cuda 1.13, PyTorch Vision 0.14 and OpenCV 3.9 (only CPU)…

Right now I´m trying to see which version of OpenCV with CUDA that I can making work (compile).


hi mrdusty,i was wondering if jetpack4.6 support torch1.13.0 or above(i saw top of this threads,just ask) becausei’ve encountered with a problem that needed me to upgrade it to 0.13.0

Hi @damgaarderik, PyTorch 1.10 was the last version to support Python 3.6 for JetPack 4.6 and Ubuntu 18.04. You can try the Q-engineering way to upgrade to 20.04, but no guarantees that CUDA/ect will still be working…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.