Installing Pycuda for TensorRT Dorcker Image

Hello,

We have to set docker environment on Jetson TX2.
The important point is we want TenworRT(>=8.2) and pycuda.

I’ve checked pycuda can install on local as below:

But it doesn’t work on docker that it is l4t-tensorrt:r8.2.1-runtime.

How to install pycuda on our environment?

Docker Run command
$ sudo docker run --runtime nvidia -it --name tensorrt-test -v /home/nvidia/test:/home/test nvcr.io/nvidia/l4t-tensorrt:r8.2.1-runtime /bin/bash

Hi,

Could you share the complete output log so we can know the issue that caused the installation failure?

Thanks.

Here it is
pycuda_install_failed.txt (4.7 KB)

Hi,

You will need some building tools and the CUDA header for Pycuda.
Please try the below inside the container:

$ apt install cuda
$ apt install build-essential python3-dev
$ pip3 install pycuda --user

Thanks.

I got stuck on first step.
image

Hi,

Please try to update the source list to see if it helps:

https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3273/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/updating_jetson_and_host.html#

Please open /etc/apt/sources.list.d/nvidia-l4t-apt-source.list and add:

deb https://repo.download.nvidia.com/jetson/common r32.4 main
deb https://repo.download.nvidia.com/jetson/t194 r32.4 main

And then run

apt update
apt install cuda

If it doesn’t work, please share the log output of apt update.
Thanks.

Installation is failed.

- apt update, before setting “nvidia-l4t-apt-source.list”

root@tx2:/# apt update
Err:1 http://cuda-internal.nvidia.com/release-candidates/kitpicks/tensorrt-rel-8-2-tegra/8.2.1/001/repos/l4t/arm64 InRelease
Could not resolve ‘cuda-internal.nvidia.com
Get:2 Index of /ubuntu-ports bionic InRelease [242 kB]
Get:3 Index of /ubuntu-ports bionic-updates InRelease [88.7 kB]
Get:4 Index of /ubuntu-ports bionic-backports InRelease [83.3 kB]
Get:5 Index of /ubuntu-ports bionic-security InRelease [88.7 kB]
Get:6 Index of /ubuntu-ports bionic/universe arm64 Packages [11.0 MB]
Get:7 Index of /ubuntu-ports bionic/multiverse arm64 Packages [153 kB]
Get:8 Index of /ubuntu-ports bionic/main arm64 Packages [1285 kB]
Get:9 Index of /ubuntu-ports bionic/restricted arm64 Packages [572 B]
Get:10 Index of /ubuntu-ports bionic-updates/universe arm64 Packages [2161 kB]
Get:11 Index of /ubuntu-ports bionic-updates/main arm64 Packages [2309 kB]
Get:12 Index of /ubuntu-ports bionic-updates/restricted arm64 Packages [6338 B]
Get:13 Index of /ubuntu-ports bionic-updates/multiverse arm64 Packages [5349 B]
Get:14 Index of /ubuntu-ports bionic-backports/universe arm64 Packages [20.1 kB]
Get:15 Index of /ubuntu-ports bionic-backports/main arm64 Packages [64.0 kB]
Get:16 Index of /ubuntu-ports bionic-security/universe arm64 Packages [1469 kB]
Get:17 Index of /ubuntu-ports bionic-security/multiverse arm64 Packages [2759 B]
Get:18 Index of /ubuntu-ports bionic-security/main arm64 Packages [1944 kB]
Get:19 Index of /ubuntu-ports bionic-security/restricted arm64 Packages [5659 B]
Fetched 20.9 MB in 9s (2258 kB/s)
Reading package lists… Done
Building dependency tree
Reading state information… Done
133 packages can be upgraded. Run ‘apt list --upgradable’ to see them.
W: Failed to fetch http://cuda-internal.nvidia.com/release-candidates/kitpicks/tensorrt-rel-8-2-tegra/8.2.1/001/repos/l4t/arm64/InRelease Could not resolve ‘cuda-internal.nvidia.com
W: Some index files failed to download. They have been ignored, or old ones used instead.
root@tx2:/#

- apt update, after setting “nvidia-l4t-apt-source.list”

root@tx2:/# apt update
Err:1 http://cuda-internal.nvidia.com/release-candidates/kitpicks/tensorrt-rel-8-2-tegra/8.2.1/001/repos/l4t/arm64 InRelease
Could not resolve ‘cuda-internal.nvidia.com
Get:2 https://repo.download.nvidia.com/jetson/common r32.4 InRelease [2552 B]
Get:3 https://repo.download.nvidia.com/jetson/t194 r32.4 InRelease [2565 B]
Hit:4 Index of /ubuntu-ports bionic InRelease
Err:2 https://repo.download.nvidia.com/jetson/common r32.4 InRelease
The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 0D296FFB880FB004
Hit:5 Index of /ubuntu-ports bionic-updates InRelease
Err:3 https://repo.download.nvidia.com/jetson/t194 r32.4 InRelease
The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 0D296FFB880FB004
Hit:6 Index of /ubuntu-ports bionic-backports InRelease
Hit:7 Index of /ubuntu-ports bionic-security InRelease
Reading package lists… Done
W: GPG error: https://repo.download.nvidia.com/jetson/common r32.4 InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 0D296FFB880FB004
E: The repository ‘https://repo.download.nvidia.com/jetson/common r32.4 InRelease’ is not signed.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: https://repo.download.nvidia.com/jetson/t194 r32.4 InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 0D296FFB880FB004
E: The repository ‘https://repo.download.nvidia.com/jetson/t194 r32.4 InRelease’ is not signed.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
root@tx2:/#

The GPG error fixed as beow:

$ apt-key adv --fetch-key https://repo.download.nvidia.com/jetson/jetson-ota-public.asc

And I deleted “/etc/apt/sourece.list.d/cuda.list

So, there is no error in now, but cuda installation is failed.

root@tx2:/# apt update
Get:1 https://repo.download.nvidia.com/jetson/common r32.4 InRelease [2552 B]
Get:2 https://repo.download.nvidia.com/jetson/t194 r32.4 InRelease [2565 B]
Hit:3 Index of /ubuntu-ports bionic InRelease
Get:4 https://repo.download.nvidia.com/jetson/common r32.4/main arm64 Packages [14.0 kB]
Hit:5 Index of /ubuntu-ports bionic-updates InRelease
Get:6 https://repo.download.nvidia.com/jetson/t194 r32.4/main arm64 Packages [22.6 kB]
Hit:7 Index of /ubuntu-ports bionic-backports InRelease
Hit:8 Index of /ubuntu-ports bionic-security InRelease
Fetched 41.7 kB in 2s (17.8 kB/s)
Reading package lists… Done
Building dependency tree
Reading state information… Done
129 packages can be upgraded. Run ‘apt list --upgradable’ to see them.
root@tx2:/#
root@tx2:/# apt install cuda
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package cuda
root@tx2:/#

Hi,

Could you try the below command?

apt-get update
apt-get install cuda

Thanks.

“apt-get” result is same as “apt”

Hi,

Could you give nvidia-cuda and nvidia-cuda-dev a try?

Thanks.

  • nvidia-cuda-dev

  • nvidiia-cuda

There are cuda packages what it is listed

root@tx2:/# apt-cache search cuda
libcupti-doc - NVIDIA CUDA Profiler Tools Interface documentation
nvidia-cuda-doc - NVIDIA CUDA and OpenCL documentation
python-pycuda-doc - module to access Nvidia??s CUDA computation API (documentation)
cuda-command-line-tools-10-2 - CUDA command-line tools
cuda-compiler-10-2 - CUDA compiler
cuda-core-10-2 - CUDA core tools
cuda-cudart-10-2 - CUDA Runtime native Libraries
cuda-cudart-dev-10-2 - CUDA Runtime native dev links, headers
cuda-cufft-10-2 - CUFFT native runtime libraries
cuda-cufft-dev-10-2 - CUFFT native dev links, headers
cuda-cuobjdump-10-2 - CUDA cuobjdump
cuda-cupti-10-2 - CUDA profiling tools runtime libs.
cuda-cupti-dev-10-2 - CUDA profiling tools interface.
cuda-curand-10-2 - CURAND native runtime libraries
cuda-curand-dev-10-2 - CURAND native dev links, headers
cuda-cusolver-10-2 - CUDA solver native runtime libraries
cuda-cusolver-dev-10-2 - CUDA solver native dev links, headers
cuda-cusparse-10-2 - CUSPARSE native runtime libraries
cuda-cusparse-dev-10-2 - CUSPARSE native dev links, headers
cuda-documentation-10-2 - CUDA documentation
cuda-driver-dev-10-2 - CUDA Driver native dev stub library
cuda-gdb-10-2 - CUDA-GDB
cuda-gdb-src-10-2 - Contains the source code for cuda-gdb
cuda-libraries-10-2 - CUDA Libraries 10.2 meta-package
cuda-libraries-dev-10-2 - CUDA Libraries 10.2 development meta-package
cuda-license-10-2 - CUDA licenses
cuda-memcheck-10-2 - CUDA-MEMCHECK
cuda-minimal-build-10-2 - Minimal CUDA 10.2 toolkit build packages.
cuda-misc-headers-10-2 - CUDA miscellaneous headers
cuda-npp-10-2 - NPP native runtime libraries
cuda-npp-dev-10-2 - NPP native dev links, headers
cuda-nvcc-10-2 - CUDA nvcc
cuda-nvdisasm-10-2 - CUDA disassembler
cuda-nvgraph-10-2 - NVGRAPH native runtime libraries
cuda-nvgraph-dev-10-2 - NVGRAPH native dev links, headers
cuda-nvml-dev-10-2 - NVML native dev links, headers
cuda-nvprof-10-2 - CUDA Profiler tools
cuda-nvprune-10-2 - CUDA nvprune
cuda-nvrtc-10-2 - NVRTC native runtime libraries
cuda-nvrtc-dev-10-2 - NVRTC native dev links, headers
cuda-nvtx-10-2 - NVIDIA Tools Extension
cuda-samples-10-2 - CUDA example applications
cuda-toolkit-10-2 - CUDA Toolkit 10.2 meta-package
cuda-tools-10-2 - CUDA Tools meta-package
nvidia-container-csv-cuda - Jetpack CUDA CSV file
nvidia-cuda - NVIDIA CUDA Meta Package
nvidia-l4t-cuda - NVIDIA CUDA Package
libcusolver-10-2 - CUDA solver native runtime libraries
libcusparse-10-2 - CUSPARSE native runtime libraries
libcufft-10-2 - CUFFT native runtime libraries
libnpp-10-2 - NPP native runtime libraries
libcurand-10-2 - CURAND native runtime libraries
root@tx2:/#

And then I tried to install “nvidia-l4t-cuda”, but it failed.

root@tx2:/# apt install nvidia-l4t-cuda
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
nvidia-l4t-3d-core nvidia-l4t-core nvidia-l4t-firmware nvidia-l4t-init nvidia-l4t-wayland nvidia-l4t-x11
The following NEW packages will be installed:
nvidia-l4t-3d-core nvidia-l4t-core nvidia-l4t-cuda nvidia-l4t-firmware nvidia-l4t-init nvidia-l4t-wayland
nvidia-l4t-x11
0 upgraded, 7 newly installed, 0 to remove and 129 not upgraded.
Need to get 34.3 MB of archives.
After this operation, 107 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://repo.download.nvidia.com/jetson/t194 r32.4/main arm64 nvidia-l4t-core arm64 32.4.4-20201016123640 [2717 kB]
Get:2 https://repo.download.nvidia.com/jetson/t194 r32.4/main arm64 nvidia-l4t-firmware arm64 32.4.4-20201027211332 [1797 kB]
Get:3 https://repo.download.nvidia.com/jetson/t194 r32.4/main arm64 nvidia-l4t-init arm64 32.4.4-20201027211332 [49.8 kB]
Get:4 https://repo.download.nvidia.com/jetson/t194 r32.4/main arm64 nvidia-l4t-wayland arm64 32.4.4-20201027211332 [21.2 kB]
Get:5 https://repo.download.nvidia.com/jetson/t194 r32.4/main arm64 nvidia-l4t-x11 arm64 32.4.4-20201027211332 [4742 B]
Get:6 https://repo.download.nvidia.com/jetson/t194 r32.4/main arm64 nvidia-l4t-3d-core arm64 32.4.4-20201027211332 [26.6 MB]
Get:7 https://repo.download.nvidia.com/jetson/t194 r32.4/main arm64 nvidia-l4t-cuda arm64 32.4.4-20201027211332 [3158 kB]
Fetched 34.3 MB in 9s (3777 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package nvidia-l4t-core.
(Reading database … 34176 files and directories currently installed.)
Preparing to unpack …/nvidia-l4t-core_32.4.4-20201016123640_arm64.deb …
/var/lib/dpkg/tmp.ci/preinst: line 40: /proc/device-tree/compatible: No such file or directory
dpkg: error processing archive /var/cache/apt/archives/nvidia-l4t-core_32.4.4-20201016123640_arm64.deb (–unpack):
new nvidia-l4t-core package pre-installation script subprocess returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/nvidia-l4t-core_32.4.4-20201016123640_arm64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@tx2:/#

Hi,

Thanks a lot for sharing the testing result.
It looks like you face something similar to topic 188459 which already has a WAR in the below comment:

Please give it a try. Based on your use case, please add the following lines to source.list after cleaning the internal repo.

deb https://repo.download.nvidia.com/jetson/common r32.4 main
deb https://repo.download.nvidia.com/jetson/t194 r32.4 main

Then it should work by running apt update && apt install cuda.
Please let us know if the WAR does not help.

Thanks.

Hello,

I did it already. you can see it on 9th post in this page.
‘cuda.llist’ is the only one file in there, after run docker image.
I removed it on all test after 9th post.

It is my process just before and it doesn’t work as same as before.

nvidia@tx2:~$ sudo docker run --runtime nvidia --net=host -it --name tensorrt-test -v /home/nvidia/test:/home/test nvcr.io/nvidia/l4t-tensorrt:r8.2.1-runtime /bin/bash
root@tx2:/#
root@tx2:/# ls /etc/apt/sources.list.d/
cuda.list
root@tx2:/# rm /etc/apt/sources.list.d/*
root@tx2:/# echo “deb https://repo.download.nvidia.com/jetson/common r32.4 main” > /etc/apt/sources.list.d/nvidia-l4t-apt-source.list
root@tx2:/# echo “deb https://repo.download.nvidia.com/jetson/t186 r32.4 main” >> /etc/apt/sources.list.d/nvidia-l4t-apt-source.list
root@tx2:/# apt-key adv --fetch-key https://repo.download.nvidia.com/jetson/jetson-ota-public.asc
Executing: /tmp/apt-key-gpghome.lJ7HOishnW/gpg.1.sh --fetch-key https://repo.download.nvidia.com/jetson/jetson-ota-public.asc
gpg: requesting key from ‘https://repo.download.nvidia.com/jetson/jetson-ota-public.asc
gpg: key E6543461A9996195: public key “NVIDIA Corporation linux-tegra-bugs@nvidia.com” imported
gpg: Total number processed: 1
gpg: imported: 1
root@tx2:/#
root@tx2:/# apt update
Get:1 https://repo.download.nvidia.com/jetson/common r32.4 InRelease [2552 B]
Get:2 https://repo.download.nvidia.com/jetson/t186 r32.4 InRelease [2564 B]
Get:3 Index of /ubuntu-ports bionic InRelease [242 kB]
Get:4 https://repo.download.nvidia.com/jetson/common r32.4/main arm64 Packages [14.0 kB]
Get:5 https://repo.download.nvidia.com/jetson/t186 r32.4/main arm64 Packages [22.6 kB]
Get:6 Index of /ubuntu-ports bionic-updates InRelease [88.7 kB]
Get:7 Index of /ubuntu-ports bionic-backports InRelease [83.3 kB]
Get:8 Index of /ubuntu-ports bionic-security InRelease [88.7 kB]
Get:9 Index of /ubuntu-ports bionic/multiverse arm64 Packages [153 kB]
Get:10 Index of /ubuntu-ports bionic/main arm64 Packages [1285 kB]
Get:11 Index of /ubuntu-ports bionic/universe arm64 Packages [11.0 MB]
Get:12 Index of /ubuntu-ports bionic/restricted arm64 Packages [572 B]
Get:13 Index of /ubuntu-ports bionic-updates/multiverse arm64 Packages [5349 B]
Get:14 Index of /ubuntu-ports bionic-updates/restricted arm64 Packages [6338 B]
Get:15 Index of /ubuntu-ports bionic-updates/main arm64 Packages [2309 kB]
Get:16 Index of /ubuntu-ports bionic-updates/universe arm64 Packages [2161 kB]
Get:17 Index of /ubuntu-ports bionic-backports/main arm64 Packages [64.0 kB]
Get:18 Index of /ubuntu-ports bionic-backports/universe arm64 Packages [20.1 kB]
Get:19 Index of /ubuntu-ports bionic-security/universe arm64 Packages [1469 kB]
Get:20 Index of /ubuntu-ports bionic-security/restricted arm64 Packages [5659 B]
Get:21 Index of /ubuntu-ports bionic-security/multiverse arm64 Packages [2759 B]
Get:22 Index of /ubuntu-ports bionic-security/main arm64 Packages [1944 kB]
Fetched 21.0 MB in 9s (2250 kB/s)
Reading package lists… Done
Building dependency tree
Reading state information… Done
133 packages can be upgraded. Run ‘apt list --upgradable’ to see them.
root@tx2:/#
root@tx2:/# apt install cuda
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package cuda
root@tx2:/#

And I already applied our requirements on JetPack5.
JetPack 5 doesn’t have this issue, It is only issued on JetPack4.

Hi,

Thanks for the update.
Let us give it a check and update.

Thanks.

Hi,

Thanks for your patience.
We can install pycuda with the below command, please give it a try:

#sudo docker run -it --rm --net=host --runtime nvidia -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix nvcr.io/nvidia/l4t-tensorrt:r8.2.1-runtime
root@nvidia-desktop:/# rm /etc/apt/sources.list.d/*
root@nvidia-desktop:/# echo "deb https://repo.download.nvidia.com/jetson/common r32.4 main" > /etc/apt/sources.list.d/nvidia-l4t-apt-source.list
root@nvidia-desktop:/# echo "deb https://repo.download.nvidia.com/jetson/t194 r32.4 main" >> /etc/apt/sources.list.d/nvidia-l4t-apt-source.list
root@nvidia-desktop:/# apt-key adv --fetch-key https://repo.download.nvidia.com/jetson/jetson-ota-public.asc
root@nvidia-desktop:/# apt update
root@nvidia-desktop:/# apt install build-essential python3.8-dev
root@nvidia-desktop:/# pip3 install pycuda --user

Collecting pycuda
  Downloading pycuda-2024.1.tar.gz (1.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 2.2 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
...
Building wheels for collected packages: pycuda
  Building wheel for pycuda (pyproject.toml) ... done
  Created wheel for pycuda: filename=pycuda-2024.1-cp38-cp38-linux_aarch64.whl size=658695 sha256=04084cfee675382b259d64b711cbce8731a2124aa808a1a732d9ea712477c704
  Stored in directory: /root/.cache/pip/wheels/fd/8a/a0/e44a2f39cf543084cdbfefa4c95273993857481b9c01355e06
Successfully built pycuda
Installing collected packages: appdirs, typing-extensions, platformdirs, MarkupSafe, pytools, mako, pycuda
  WARNING: The script mako-render is installed in '/root/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed MarkupSafe-2.1.5 appdirs-1.4.4 mako-1.3.2 platformdirs-4.2.0 pycuda-2024.1 pytools-2023.1.1 typing-extensions-4.10.0

Thanks.

1 Like

Thank you it works for me.

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