Which nvidia packages are needed to run pytorch?

Hello,

I want to create a minimal linux image with the prebuild pytorch 2.0.0 installed following the installation guide. My question is which jetpack packages do I need for pytorch to work? I installed the following packages sudo apt install cuda-toolkit-11.4 nvidia-cudnn8. With these packages import torch works but they are quite big. Can I install less big packages to get pytorch working? For instance do I even need to install cudnn or is it included in the pytorch wheel?

Thanks.

Hi @Xennor, I haven’t personally tried this before so I’m not sure what the exact list of required packages is, but I would start by inspecting which libraries the torch C modules link against:

ldd /usr/local/lib/python3.8/dist-packages/torch/_C.cpython-38-aarch64-linux-gnu.so
        linux-vdso.so.1 (0x0000ffff93a26000)
        libtorch_python.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libtorch_python.so (0x0000ffff92e61000)
        libshm.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libshm.so (0x0000ffff92e49000)
        libtorch.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libtorch.so (0x0000ffff92e37000)
        libnvToolsExt.so.1 => /usr/local/cuda-11.4/lib64/libnvToolsExt.so.1 (0x0000ffff92e1b000)
        libtorch_cpu.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libtorch_cpu.so (0x0000ffff8e6c9000)
        libtorch_cuda.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libtorch_cuda.so (0x0000ffff7f2c9000)
        libc10_cuda.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libc10_cuda.so (0x0000ffff7f26a000)
        libcudart.so.11.0 => /usr/local/cuda-11.4/lib64/libcudart.so.11.0 (0x0000ffff7f1ae000)
        libcudnn.so.8 => /lib/aarch64-linux-gnu/libcudnn.so.8 (0x0000ffff7f153000)
        libc10.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libc10.so (0x0000ffff7f0dc000)
        libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000ffff7eef7000)
        libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000ffff7eed3000)
        libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000ffff7eea2000)
        libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffff7ed2f000)
        /lib/ld-linux-aarch64.so.1 (0x0000ffff939f6000)
        librt.so.1 => /lib/aarch64-linux-gnu/librt.so.1 (0x0000ffff7ed17000)
        libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000ffff7ed03000)
        libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000ffff7ec58000)
        libgomp.so.1 => /lib/aarch64-linux-gnu/libgomp.so.1 (0x0000ffff7ec0a000)
        libnuma.so.1 => /lib/aarch64-linux-gnu/libnuma.so.1 (0x0000ffff7ebeb000)
        libopenblas.so.0 => /lib/aarch64-linux-gnu/libopenblas.so.0 (0x0000ffff7dd53000)
        libcusparse.so.11 => /usr/local/cuda-11.4/lib64/libcusparse.so.11 (0x0000ffff700ac000)
        libcurand.so.10 => /usr/local/cuda-11.4/lib64/libcurand.so.10 (0x0000ffff6b002000)
        libcusolver.so.11 => /usr/local/cuda-11.4/lib64/libcusolver.so.11 (0x0000ffff5dea4000)
        libcufft.so.10 => /usr/local/cuda-11.4/lib64/libcufft.so.10 (0x0000ffff52f3c000)
        libcublas.so.11 => /usr/local/cuda-11.4/lib64/libcublas.so.11 (0x0000ffff48e63000)
        libgfortran.so.5 => /lib/aarch64-linux-gnu/libgfortran.so.5 (0x0000ffff48ce8000)
        libcublasLt.so.11 => /usr/local/cuda-11.4/lib64/libcublasLt.so.11 (0x0000ffff31747000)
ldd /usr/local/lib/python3.8/dist-packages/torch/lib/libtorch_cuda.so
        linux-vdso.so.1 (0x0000ffff9a38d000)
        libc10_cuda.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libc10_cuda.so (0x0000ffff8aefe000)
        libcudart.so.11.0 => /usr/local/cuda-11.4/lib64/libcudart.so.11.0 (0x0000ffff8ae42000)
        libcusparse.so.11 => /usr/local/cuda-11.4/lib64/libcusparse.so.11 (0x0000ffff7d19b000)
        libcurand.so.10 => /usr/local/cuda-11.4/lib64/libcurand.so.10 (0x0000ffff780f1000)
        libcusolver.so.11 => /usr/local/cuda-11.4/lib64/libcusolver.so.11 (0x0000ffff6af93000)
        libnvToolsExt.so.1 => /usr/local/cuda-11.4/lib64/libnvToolsExt.so.1 (0x0000ffff6af77000)
        libc10.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libc10.so (0x0000ffff6af00000)
        libtorch_cpu.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libtorch_cpu.so (0x0000ffff667ae000)
        libcufft.so.10 => /usr/local/cuda-11.4/lib64/libcufft.so.10 (0x0000ffff5b846000)
        libcublas.so.11 => /usr/local/cuda-11.4/lib64/libcublas.so.11 (0x0000ffff5176d000)
        libcudnn.so.8 => /lib/aarch64-linux-gnu/libcudnn.so.8 (0x0000ffff51712000)
        libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000ffff5152d000)
        libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000ffff51482000)
        libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000ffff5145e000)
        libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffff512eb000)
        /lib/ld-linux-aarch64.so.1 (0x0000ffff9a35d000)
        libgomp.so.1 => /lib/aarch64-linux-gnu/libgomp.so.1 (0x0000ffff5129d000)
        libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000ffff5126c000)
        libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000ffff51258000)
        librt.so.1 => /lib/aarch64-linux-gnu/librt.so.1 (0x0000ffff51240000)
        libcublasLt.so.11 => /usr/local/cuda-11.4/lib64/libcublasLt.so.11 (0x0000ffff39c9f000)
        libnuma.so.1 => /lib/aarch64-linux-gnu/libnuma.so.1 (0x0000ffff39c80000)
        libopenblas.so.0 => /lib/aarch64-linux-gnu/libopenblas.so.0 (0x0000ffff38de8000)
        libgfortran.so.5 => /lib/aarch64-linux-gnu/libgfortran.so.5 (0x0000ffff38c6d000)

And then install the needed packages until the dependencies are met:

sudo apt-get install libcudnn8 cuda-cudart-11-4 libcublas-11-4 libcurand-11-4 \
   libcufft-11-4 libcusparse-11-4 libcusolver-11-4 libopenblas-base

This might be a partial list and you might need to add others based on what’s required. You can search for the packages with apt-cache search

Hi dusty_nv,

thank you for your answer. I got it working with:

sudo apt-get install libcudnn8 cuda-cudart-11-4 libcublas-11-4 libcurand-11-4 libcufft-11-4 \
      libcusparse-11-4 libcusolver-11-4 libopenblas-base cuda-nvtx-11-4

I added cuda-nvtx-11-4 for libnvToolsExt.so.

For tensorrt optimisation we also need:

sudo apt-get install nvidia-tensorrt python3-libnvinfer libcudla-11-4

Completely unrelated to this is that cudnn does not match the prebuild pytorch 2.0.0 version:

Python 3.8.10 (default, May 26 2023, 14:05:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.backends.cudnn.version()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/el_seamsensor/.local/lib/python3.8/site-packages/torch/backends/cudnn/__init__.py", line 70, in version
    if not _init():
  File "/home/el_seamsensor/.local/lib/python3.8/site-packages/torch/backends/cudnn/__init__.py", line 52, in _init
    raise RuntimeError(f'{base_error_msg}'
RuntimeError: cuDNN version incompatibility: PyTorch was compiled  against (8, 6, 0) but found runtime version (8, 4, 1). PyTorch already comes bundled with cuDNN. One option to resolving this error is to ensure PyTorch can find the bundled cuDNN.Looks like your LD_LIBRARY_PATH contains incompatible version of cudnnPlease either remove it from the path or install cudnn (8, 6, 0)

Is this an issue?

Hi @Xennor, what does apt-cache show libcudnn8 show for you?

$ apt-cache show libcudnn8
Package: libcudnn8
Source: cudnn
Version: 8.6.0.166-1+cuda11.4
Architecture: arm64
Maintainer: cudatools <cudatools@nvidia.com>
Installed-Size: 1141333
Priority: optional
Section: multiverse/libs
Filename: pool/main/c/cudnn/libcudnn8_8.6.0.166-1+cuda11.4_arm64.deb
Size: 394124518
SHA256: 4a679b9676d4d1bfd2d7a3572eefc916706219ad006e38a8fd2377067fd635ee
SHA1: dd33b8fbf3ed1577165a3feea5823e75631c2ad9
MD5sum: de3f5661fd34bd5220de2cb911b99ae7
Description: cuDNN runtime libraries
 cuDNN runtime libraries containing primitives for deep neural networks.
Description-md5: 0f50478914081182f91de6bc0162e2cb

This was from JetPack 5.1 and shows cuDNN 8.6. Which version of JetPack are you running? I’d recommend upgrading to the latest to be compatible with that PyTorch wheel (or try an older PyTorch wheel)

Hi I found the problem,

had the wrong deb archive selected.

cat /etc/nv_tegra_release
# R35 (release), REVISION: 3.1, GCID: 32827747, BOARD: t186ref, EABI: aarch64, DATE: Sun Mar 19 15:19:21 UTC 2023

cat /etc/apt/sources.list.d/nvidia-l4t-apt-source.list
# SPDX-FileCopyrightText: Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LicenseRef-NvidiaProprietary
#
# NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
# property and proprietary rights in and to this material, related
# documentation and any modifications thereto. Any use, reproduction,
# disclosure or distribution of this material and related documentation
# without an express license agreement from NVIDIA CORPORATION or
# its affiliates is strictly prohibited.

deb https://repo.download.nvidia.com/jetson/common r35.1 main
deb https://repo.download.nvidia.com/jetson/t194 r35.1 main

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