How to install torch, onnxruntimegpu,cuda,opencv … (use GPU) on jetson NX jetpack502. I need tutorial . Thanks
Hi,
CUDA is preinstalled with JetPack5.0.2.
OpenCV is also preinstalled with JetPack 5.0.2.
If you have CUDA enabled, please check the below script":
https://github.com/AastaNV/JEP/blob/master/script/install_opencv4.6.0_Jetson.sh
PyTorch installation guide: Installing PyTorch for Jetson Platform - NVIDIA Docs
ONNXRuntime installation guide: Jetson Zoo - eLinux.org
Thanks.
i have problem is torch.cuda.is_available() = False and ort.get_device() = CPU . Thanks so much for helping me. i’m newbie
I deleted cuda 11.4 and installed cuda 11.8
Then I installed following instructions: Start Locally | PyTorch : pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
=> torch version 2.0.1, torchvision 0.15.2
But torch.cuda.is_available() = False
@nguyen.thai.son1 those wheels from pytorch.org aren’t built for JetPack and won’t work with CUDA on Jetson. Instead, please install the PyTorch wheel from the link that @AastaLLL linked to or from here: https://forums.developer.nvidia.com/t/pytorch-for-jetson
If you are still having issues with PyTorch to have CUDA/cuDNN working, you can also try the l4t-pytorch or l4t-ml containers which already have that pre-installed. Those containers also have OpenCV+CUDA already installed in them.
Thanks. I follow the instructions https://forums.developer.nvidia.com/t/pytorch-for-jetson
import torch
torch.version
‘1.13.0a0+d0d6b1f2.nv22.09’
torch.cuda.is_available()
True
But when i installed torchvision :
sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libopenblas-dev libavcodec-dev libavformat-dev libswscale-dev
git clone --branch v0.13.0 GitHub - pytorch/vision: Datasets, Transforms and Models specific to Computer Vision torchvision
cd torchvision
export BUILD_VERSION=0.13.0
python3 setup.py install --user
=====> [Building wheel torchvision-0.13.0
PNG found: True
libpng version: 1.6.37
Building torchvision with PNG image support
libpng include path: /usr/include/libpng16
Running build on conda-build: False
Running build on conda: False
JPEG found: True
Building torchvision with JPEG image support
NVJPEG found: False
FFmpeg found: False
video codec found: False
The installed version of ffmpeg is missing the header file ‘bsf.h’ which is required for GPU video decoding. Please install the latest ffmpeg from conda-forge channel: conda install -c conda-forge ffmpeg
.
running install
running bdist_egg
running egg_info
writing torchvision.egg-info/PKG-INFO
writing dependency_links to torchvision.egg-info/dependency_links.txt
writing requirements to torchvision.egg-info/requires.txt
writing top-level names to torchvision.egg-info/top_level.txt
/home/mq/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py:472: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja… Falling back to using the slow distutils backend.
warnings.warn(msg.format(‘we could not find ninja.’))
reading manifest file ‘torchvision.egg-info/SOURCES.txt’
reading manifest template ‘MANIFEST.in’
warning: no previously-included files matching ‘pycache’ found under directory ‘’
warning: no previously-included files matching '.py[co]’ found under directory ‘*’
writing manifest file ‘torchvision.egg-info/SOURCES.txt’
installing library code to build/bdist.linux-aarch64/egg
running install_lib
running build_py
copying torchvision/version.py → build/lib.linux-aarch64-3.8/torchvision
running build_ext
Traceback (most recent call last):
File “setup.py”, line 514, in
setup(
File “/usr/lib/python3/dist-packages/setuptools/init.py”, line 144, in setup
return distutils.core.setup(**attrs)
File “/usr/lib/python3.8/distutils/core.py”, line 148, in setup
dist.run_commands()
File “/usr/lib/python3.8/distutils/dist.py”, line 966, in run_commands
self.run_command(cmd)
File “/usr/lib/python3.8/distutils/dist.py”, line 985, in run_command
cmd_obj.run()
File “/usr/lib/python3/dist-packages/setuptools/command/install.py”, line 67, in run
self.do_egg_install()
File “/usr/lib/python3/dist-packages/setuptools/command/install.py”, line 109, in do_egg_install
self.run_command(‘bdist_egg’)
File “/usr/lib/python3.8/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.8/distutils/dist.py”, line 985, in run_command
cmd_obj.run()
File “/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py”, line 172, in run
cmd = self.call_command(‘install_lib’, warn_dir=0)
File “/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py”, line 158, in call_command
self.run_command(cmdname)
File “/usr/lib/python3.8/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.8/distutils/dist.py”, line 985, in run_command
cmd_obj.run()
File “/usr/lib/python3/dist-packages/setuptools/command/install_lib.py”, line 23, in run
self.build()
File “/usr/lib/python3.8/distutils/command/install_lib.py”, line 109, in build
self.run_command(‘build_ext’)
File “/usr/lib/python3.8/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.8/distutils/dist.py”, line 985, in run_command
cmd_obj.run()
File “/usr/lib/python3/dist-packages/setuptools/command/build_ext.py”, line 87, in run
_build_ext.run(self)
File “/home/mq/.local/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py”, line 186, in run
_build_ext.build_ext.run(self)
File “/usr/lib/python3.8/distutils/command/build_ext.py”, line 340, in run
self.build_extensions()
File “/home/mq/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py”, line 495, in build_extensions
_check_cuda_version(compiler_name, compiler_version)
File “/home/mq/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py”, line 382, in _check_cuda_version
raise RuntimeError(CUDA_MISMATCH_MESSAGE.format(cuda_str_version, torch.version.cuda))
RuntimeError:
The detected CUDA version (11.8) mismatches the version that was used to compile
PyTorch (11.4). Please make sure to use the same CUDA versions.]
Please help me to solve it, thank you very much
@nguyen.thai.son1 you need to uninstall CUDA 11.8 and restore the original CUDA 11.4 version that came with JetPack
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.