Jetson container package torch2trt on nano orin 8gb Developement kit


I have a jetson orin nano 8gb development kit. When I try to build a container using jetson_containers. I want to include several packages in the container.

– L4T_VERSION=35.4.1
– CUDA_VERSION=11.4.315
– LSB_RELEASE=20.04 (focal)

I run the command

./ --name=arsd ros:foxy-desktop realsense pytorch l4t-pytorch cuda-python opencv

and I am getting the following error:


sourcing   /opt/ros/foxy/install/setup.bash
ROS_ROOT   /opt/ros/foxy
testing torchaudio...
torchaudio version: 2.0.1+3b40834
found audio backend 'sox_io' OK
found audio backend 'soundfile' OK
torchaudio OK

-- Building container arsd:r35.4.1-torch2trt

docker build --network=host --tag arsd:r35.4.1-torch2trt \
--file /home/omar/jetson-containers/packages/pytorch/torch2trt/Dockerfile \
--build-arg BASE_IMAGE=arsd:r35.4.1-torchaudio \
--build-arg CUDA_ARCHITECTURES="72;87" \
/home/omar/jetson-containers/packages/pytorch/torch2trt \
2>&1 | tee /home/omar/jetson-containers/logs/20230906_175907/build/arsd_r35.4.1-torch2trt.txt; exit ${PIPESTATUS[0]}

DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:

Sending build context to Docker daemon  12.29kB
Step 2/5 : FROM ${BASE_IMAGE}
 ---> 609527e96ea4
 ---> Using cache
 ---> b381ce7940be
Step 4/5 : RUN cd /opt &&     git clone --depth=1 &&     cd torch2trt &&     pip3 install --verbose . &&     sed 's|^set(CUDA_ARCHITECTURES.*|#|g' -i CMakeLists.txt &&     cmake -B build -DCUDA_ARCHITECTURES=${CUDA_ARCHITECTURES} . &&     cmake --build build --target install &&     ldconfig
 ---> Running in 98dea35b1daf
Cloning into 'torch2trt'...
Using pip 23.2.1 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
Processing /opt/torch2trt
  Preparing metadata ( started
  Running command python egg_info
  Traceback (most recent call last):
    File "<string>", line 2, in <module>
    File "<pip-setuptools-caller>", line 34, in <module>
    File "/opt/torch2trt/", line 2, in <module>
      import tensorrt
    File "/usr/lib/python3.8/dist-packages/tensorrt/", line 68, in <module>
      from .tensorrt import *
  ImportError: cannot open shared object file: No such file or directory
  error: subprocess-exited-with-error
  × python egg_info did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /usr/bin/python3 -c '
  # This is <pip-setuptools-caller> -- a caller that pip uses to run
  # - It imports setuptools before invoking, to enable projects that directly
  #   import from `distutils.core` to work with newer packaging standards.
  # - It provides a clear error message when setuptools is not installed.
  # - It sets `sys.argv[0]` to the underlying ``, when invoking `` so
  #   setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
  #     manifest_maker: standard file '"'"'-c'"'"' not found".
  # - It generates a shim, for handling setup.cfg-only projects.
  import os, sys, tokenize
      import setuptools
  except ImportError as error:
          "ERROR: Can not execute `` since setuptools is not available in "
          "the build environment.",
  __file__ = %r
  sys.argv[0] = __file__
  if os.path.exists(__file__):
      filename = __file__
      with as f:
          setup_py_code =
      filename = "<auto-generated setuptools caller>"
      setup_py_code = "from setuptools import setup; setup()"
  exec(compile(setup_py_code, filename, "exec"))
  '"'"''"'"''"'"' % ('"'"'/opt/torch2trt/'"'"',), "<pip-setuptools-caller>", "exec"))' egg_info --egg-base /tmp/pip-pip-egg-info-skhimh29
  cwd: /opt/torch2trt/
  Preparing metadata ( finished with status 'error'
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
The command '/bin/bash -c cd /opt &&     git clone --depth=1 &&     cd torch2trt &&     pip3 install --verbose . &&     sed 's|^set(CUDA_ARCHITECTURES.*|#|g' -i CMakeLists.txt &&     cmake -B build -DCUDA_ARCHITECTURES=${CUDA_ARCHITECTURES} . &&     cmake --build build --target install &&     ldconfig' returned a non-zero code: 1
Traceback (most recent call last):
  File "/usr/lib/python3.8/", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/", line 87, in _run_code
    exec(code, run_globals)
  File "/home/omar/jetson-containers/jetson_containers/", line 93, in <module>
    build_container(, args.packages, args.base, args.build_flags, args.simulate, args.skip_tests, args.push)
  File "/home/omar/jetson-containers/jetson_containers/", line 119, in build_container
    status =, ' '), executable='/bin/bash', shell=True, check=True)  
  File "/usr/lib/python3.8/", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'docker build --network=host --tag arsd:r35.4.1-torch2trt --file /home/omar/jetson-containers/packages/pytorch/torch2trt/Dockerfile --build-arg BASE_IMAGE=arsd:r35.4.1-torchaudio --build-arg CUDA_ARCHITECTURES="72;87" /home/omar/jetson-containers/packages/pytorch/torch2trt 2>&1 | tee /home/omar/jetson-containers/logs/20230906_175907/build/arsd_r35.4.1-torch2trt.txt; exit ${PIPESTATUS[0]}' returned non-zero exit status 1.

I can find the file under /usr/lib/aarch64-linux-gnu/tegra/

Additionally, I was wondering if it is possible to install buildx plugin on the jetson orin nano.

Thanks in advance :)

Hi @o.zayed, have you set your default docker runtime to nvidia like in the setup guide?

I had problems with buildkit in the past, with it not using the nvidia runtime during builds.

Also, see this recent post (it seems that the ordering of ROS/PyTorch in the package list matters)

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