problem with installing ONNX on jetson nano

Hey guys,
could anyone help me,
trying to install onnx on jetson nano and after using: pip install onnx
i got the next errors:

Building wheel for onnx (setup.py) … error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-40juttb4/onnx/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-40juttb4/onnx/setup.py’“'”‘;f=getattr(tokenize, ‘"’“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ bdist_wheel -d /tmp/pip-wheel-2igdvv_2
cwd: /tmp/pip-install-40juttb4/onnx/
Complete output (122 lines):
fatal: not a git repository (or any of the parent directories): .git
running bdist_wheel
running build
running build_py
running create_version
running cmake_build
– Build type not set - defaulting to Release
– The C compiler identification is GNU 7.4.0
– The CXX compiler identification is GNU 7.4.0
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: /usr/bin/c++
– Check for working CXX compiler: /usr/bin/c++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Looking for pthread.h
– Looking for pthread.h - found
– Looking for pthread_create
– Looking for pthread_create - not found
– Looking for pthread_create in pthreads
– Looking for pthread_create in pthreads - not found
– Looking for pthread_create in pthread
– Looking for pthread_create in pthread - found
– Found Threads: TRUE
– Found Protobuf: /usr/local/lib/libprotobuf.so;-lpthread (found version “3.11.2”)
– Found PythonInterp: /usr/bin/python3 (found version “3.6.9”)
– Found PythonLibs: /usr/lib/aarch64-linux-gnu/libpython3.6m.so

– ******** Summary ********
– CMake version : 3.10.2
– CMake command : /usr/bin/cmake
– System : Linux
– C++ compiler : /usr/bin/c++
– C++ compiler version : 7.4.0
– CXX flags : -Wnon-virtual-dtor
– Build type : Release
– Compile definitions :
– CMAKE_PREFIX_PATH :
– CMAKE_INSTALL_PREFIX : /usr/local
– CMAKE_MODULE_PATH : /usr/local/share/cmake/pybind11

– ONNX version : 1.4.1
– ONNX NAMESPACE : onnx
– ONNX_BUILD_TESTS : OFF
– ONNX_BUILD_BENCHMARKS : OFF
– ONNX_USE_LITE_PROTO : OFF
– ONNXIFI_DUMMY_BACKEND : OFF

– Protobuf compiler : /usr/local/bin/protoc
– Protobuf includes : /usr/local/include
– Protobuf libraries : /usr/local/lib/libprotobuf.so;-lpthread
– BUILD_ONNX_PYTHON : ON
– Python version :
– Python executable : /usr/bin/python3
– Python includes : /usr/include/python3.6m
– Configuring done
– Generating done
– Build files have been written to: /tmp/pip-install-40juttb4/onnx/.setuptools-cmake-build
Scanning dependencies of target gen_onnx_proto
Scanning dependencies of target onnxifi_dummy
Scanning dependencies of target onnxifi_loader
[ 3%] Running gen_proto.py on onnx/onnx.in.proto
[ 3%] Building C object CMakeFiles/onnxifi_dummy.dir/onnx/onnxifi_dummy.c.o
[ 5%] Building C object CMakeFiles/onnxifi_loader.dir/onnx/onnxifi_loader.c.o
Processing /tmp/pip-install-40juttb4/onnx/onnx/onnx.in.proto
Writing /tmp/pip-install-40juttb4/onnx/.setuptools-cmake-build/onnx/onnx.proto
Writing /tmp/pip-install-40juttb4/onnx/.setuptools-cmake-build/onnx/onnx.proto3
generating /tmp/pip-install-40juttb4/onnx/.setuptools-cmake-build/onnx/onnx_pb.py
[ 7%] Linking C static library libonnxifi_loader.a
[ 9%] Running C++ protocol buffer compiler on /tmp/pip-install-40juttb4/onnx/.setuptools-cmake-build/onnx/onnx.proto
[ 11%] Linking C shared library libonnxifi_dummy.so
–python_out: onnx/onnx.proto: Unknown generator option: dllexport_decl
CMakeFiles/gen_onnx_proto.dir/build.make:61: recipe for target ‘onnx/onnx.pb.cc’ failed
make[2]: *** [onnx/onnx.pb.cc] Error 1
CMakeFiles/Makefile2:210: recipe for target ‘CMakeFiles/gen_onnx_proto.dir/all’ failed
make[1]: *** [CMakeFiles/gen_onnx_proto.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…
[ 11%] Built target onnxifi_loader
[ 11%] Built target onnxifi_dummy
Makefile:129: recipe for target ‘all’ failed
make: *** [all] Error 2
Traceback (most recent call last):
File “”, line 1, in
File “/tmp/pip-install-40juttb4/onnx/setup.py”, line 328, in
‘backend-test-tools = onnx.backend.test.cmd_tools:main’,
File “/usr/local/lib/python3.6/dist-packages/setuptools/init.py”, line 145, in setup
return distutils.core.setup(**attrs)
File “/usr/lib/python3.6/distutils/core.py”, line 148, in setup
dist.run_commands()
File “/usr/lib/python3.6/distutils/dist.py”, line 955, in run_commands
self.run_command(cmd)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/usr/local/lib/python3.6/dist-packages/wheel/bdist_wheel.py”, line 192, in run
self.run_command(‘build’)
File “/usr/lib/python3.6/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/usr/lib/python3.6/distutils/command/build.py”, line 135, in run
self.run_command(cmd_name)
File “/usr/lib/python3.6/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/tmp/pip-install-40juttb4/onnx/setup.py”, line 203, in run
self.run_command(‘cmake_build’)
File “/usr/lib/python3.6/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/tmp/pip-install-40juttb4/onnx/setup.py”, line 197, in run
subprocess.check_call(build_args)
File “/usr/lib/python3.6/subprocess.py”, line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[’/usr/bin/cmake’, ‘–build’, ‘.’, ‘–’, ‘-j’, ‘4’]’ returned non-zero exit status 2.

ERROR: Failed building wheel for onnx
Running setup.py clean for onnx
Failed to build onnx
Installing collected packages: onnx
Running setup.py install for onnx … error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-40juttb4/onnx/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-40juttb4/onnx/setup.py’“'”‘;f=getattr(tokenize, ‘"’“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’“‘))’ install --record /tmp/pip-record-h831p_pe/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/kamil/.local/include/python3.6m/onnx
cwd: /tmp/pip-install-40juttb4/onnx/
Complete output (89 lines):
fatal: not a git repository (or any of the parent directories): .git
running install
running build
running build_py
running create_version
running cmake_build

– ******** Summary ********
– CMake version : 3.10.2
– CMake command : /usr/bin/cmake
– System : Linux
– C++ compiler : /usr/bin/c++
– C++ compiler version : 7.4.0
– CXX flags : -Wnon-virtual-dtor
– Build type : Release
– Compile definitions :
– CMAKE_PREFIX_PATH :
– CMAKE_INSTALL_PREFIX : /usr/local
– CMAKE_MODULE_PATH : /usr/local/share/cmake/pybind11

– ONNX version : 1.4.1
– ONNX NAMESPACE : onnx
– ONNX_BUILD_TESTS : OFF
– ONNX_BUILD_BENCHMARKS : OFF
– ONNX_USE_LITE_PROTO : OFF
– ONNXIFI_DUMMY_BACKEND : OFF

– Protobuf compiler : /usr/local/bin/protoc
– Protobuf includes : /usr/local/include
– Protobuf libraries : /usr/local/lib/libprotobuf.so;-lpthread
– BUILD_ONNX_PYTHON : ON
– Python version :
– Python executable : /usr/bin/python3
– Python includes : /usr/include/python3.6m
– Configuring done
– Generating done
– Build files have been written to: /tmp/pip-install-40juttb4/onnx/.setuptools-cmake-build
[ 5%] Running C++ protocol buffer compiler on /tmp/pip-install-40juttb4/onnx/.setuptools-cmake-build/onnx/onnx.proto
[ 5%] Built target onnxifi_dummy
[ 9%] Built target onnxifi_loader
Scanning dependencies of target onnxifi_wrapper
–python_out: onnx/onnx.proto: Unknown generator option: dllexport_decl
CMakeFiles/gen_onnx_proto.dir/build.make:61: recipe for target ‘onnx/onnx.pb.cc’ failed
make[2]: *** [onnx/onnx.pb.cc] Error 1
CMakeFiles/Makefile2:210: recipe for target ‘CMakeFiles/gen_onnx_proto.dir/all’ failed
make[1]: *** [CMakeFiles/gen_onnx_proto.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…
[ 11%] Building C object CMakeFiles/onnxifi_wrapper.dir/onnx/onnxifi_wrapper.c.o
[ 12%] Linking C shared module libonnxifi.so
[ 12%] Built target onnxifi_wrapper
Makefile:129: recipe for target ‘all’ failed
make: *** [all] Error 2
Traceback (most recent call last):
File “”, line 1, in
File “/tmp/pip-install-40juttb4/onnx/setup.py”, line 328, in
‘backend-test-tools = onnx.backend.test.cmd_tools:main’,
File “/usr/local/lib/python3.6/dist-packages/setuptools/init.py”, line 145, in setup
return distutils.core.setup(**attrs)
File “/usr/lib/python3.6/distutils/core.py”, line 148, in setup
dist.run_commands()
File “/usr/lib/python3.6/distutils/dist.py”, line 955, in run_commands
self.run_command(cmd)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/usr/local/lib/python3.6/dist-packages/setuptools/command/install.py”, line 61, in run
return orig.install.run(self)
File “/usr/lib/python3.6/distutils/command/install.py”, line 589, in run
self.run_command(‘build’)
File “/usr/lib/python3.6/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/usr/lib/python3.6/distutils/command/build.py”, line 135, in run
self.run_command(cmd_name)
File “/usr/lib/python3.6/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/tmp/pip-install-40juttb4/onnx/setup.py”, line 203, in run
self.run_command(‘cmake_build’)
File “/usr/lib/python3.6/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/tmp/pip-install-40juttb4/onnx/setup.py”, line 197, in run
subprocess.check_call(build_args)
File “/usr/lib/python3.6/subprocess.py”, line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[’/usr/bin/cmake’, ‘–build’, ‘.’, ‘–’, ‘-j’, ‘4’]’ returned non-zero exit status 2.
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '”‘"’/tmp/pip-install-40juttb4/onnx/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-40juttb4/onnx/setup.py’“'”‘;f=getattr(tokenize, ‘"’“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ install --record /tmp/pip-record-h831p_pe/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/kamil/.local/include/python3.6m/onnx Check the logs for full command output.
k

was trying to install it with sudo or pip3 or older version like 1.4.1 and it’s not working
any help please?

i am trying to run the example about yolo

Hi,
Please check if you can apply
https://github.com/onnx/onnx/pull/2482

Hey man,
thanks for the help :)
you can close the topic

I’m having the same error and I don’t understand how to apply DaneLLL’s suggestion. Since I’m trying to do a pip2 install of onnx (1.5.0) how can i apply a patch/fix from onnx source ? Should I try installing a higher version of onnx like 1.7.0 through pip2? I’m also trying to follow the README instructions in : tensorrt/samples/python/yolov3_onnx

pip2 install on agx xavier only has access to onnx version up to 1.6.0 and that fails with the same error as well.

Hi @dilip.s, I was just able to install onnx 1.6.0 package using the following steps:

$ sudo apt-get install python-pip protobuf-compiler libprotoc-dev
$ pip install Cython --user
$ pip install onnx --user --verbose
3 Likes

Hello Dusty,

Thanks for your response. I’m trying to follow instructions README.md provided in /usr/src/tensorrt/samples/python/yolov3_onnx on my jetson Xavier eval platform.

  1. Install onnx-tensorrt (GitHub - onnx/onnx-tensorrt: ONNX-TensorRT: TensorRT backend for ONNX). But the master branch requires tensorrt 7.0, i have tensorrt 6.0 (installed as part of jetpack i think). So I pulled onnx-tensorrt 6.0-full dims branch.
  2. Dependency of onnx-tensorrt 6.0 was protobuf 3.8.x or higher so I cloned and built latest protobuf release (3.11.x). There was a missing pybind11 which resulted in build error, so i ended up cloning and building that. With this I built onnx-tenssort 6.0
  3. The yolov3_onnx required me to next install python2 -m pip install -r requirements.txt. On of the requirements was onnx 1.5.0 which is what is failing to install/build through pip.

If i do an apt-get install of protobuf-compiler and libprotoc-dev, protobuf 3.0 gets installed which will break dependency requirement on onnx-tensorrt. Cython was not mentioned in any documentation, but I installed it following your suggestion but my onnx install still fails. Also, I’m required to install these libraries for python2 as yolov3_to_onnx.py` script does not support Python 3 per the README.

Maybe I’m missing something (or a lot) but I’m finding it incredibly hard to make progress trying to follow instructions provided. I’ll really appreciate some help.

Thanks,
Dilip.

It looks like we have made some updates to the documentation for this sample for the next version of JetPack, sorry about that. From browsing the code, I’m not sure that onnx-tensorrt is actually required, or perhaps dependency was removed. I think it just uses onnx and for runtime the TensorRT python API (already installed).

If your installation of onnx is still failing, it might be that your environment has gotten mismatched versions somewhere from everything you’ve tried, as pip was just able to build it from source on my Jetson straight away.

1 Like

Thank you so much for your prompt response. Maybe I do have mismatched version, but I’m not sure how to debug. What would you suggest to try so I can move forward with onnx install ? For context, this is the error I’m seeing with onnx pip install:

“Scanning dependencies of target onnxifi_wrapper
[ 9%] Building C object CMakeFiles/onnxifi_wrapper.dir/onnx/onnxifi_wrapper.c.o
–python_out: onnx/onnx-ml.proto: Unknown generator option: dllexport_decl
CMakeFiles/gen_onnx_proto.dir/build.make:61: recipe for target ‘onnx/onnx-ml.pb.cc’ failed
make[2]: *** [onnx/onnx-ml.pb.cc] Error 1
CMakeFiles/Makefile2:210: recipe for target ‘CMakeFiles/gen_onnx_proto.dir/all’ failed
make[1]: *** [CMakeFiles/gen_onnx_proto.dir/all] Error 2”

-Dilip.

Hello dusty,

You were right, I guess my environment got messed up with multiple versions of protobuf. For some reason, automatic uninstall options like make clean (cmake) and sudo apt-get remove were not cleaning up properly. I manually deleted all protobuf related files in /usr/local/lib, /usr/local/bin and /usr/local/include and was able to successfully pip install onnx (1.5.0).

Since the README in (/samples/yolov3_onnx) mentioned onnx-tensorrt as a dependency, I built protobuf 3.10.1 from source and was also able to successfully build onnx-tensorrt (6.0-full-dims). If this is not a required dependency then installing onnx would have been simpler.

Anyway, thank you so much for your suggestions. Now I can move forward and try using the utilities to convert yolov3 weights to onnx and then to trt for inference on xavier.

Hello @dusty_nv,

I tried to install onnx with
pip install onnx --user

but, got the error:
Collecting onnx
Using cached onnx-1.7.0.tar.gz (5.5 MB)
Installing build dependencies … done
Getting requirements to build wheel … done
Installing backend dependencies … done
Preparing wheel metadata … error
ERROR: Command errored out with exit status 1:
command: /home/xxxxxxxx/venv/bin/python3 /home/xxxxxxxx/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp02z0d21i
cwd: /tmp/pip-install-bafkk6n7/onnx
Complete output (43 lines):
fatal: not a git repository (or any of the parent directories): .git
running dist_info
creating /tmp/pip-modern-metadata-h3mth73v/onnx.egg-info
writing /tmp/pip-modern-metadata-h3mth73v/onnx.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-modern-metadata-h3mth73v/onnx.egg-info/dependency_links.txt
writing entry points to /tmp/pip-modern-metadata-h3mth73v/onnx.egg-info/entry_points.txt
writing requirements to /tmp/pip-modern-metadata-h3mth73v/onnx.egg-info/requires.txt
writing top-level names to /tmp/pip-modern-metadata-h3mth73v/onnx.egg-info/top_level.txt
writing manifest file ‘/tmp/pip-modern-metadata-h3mth73v/onnx.egg-info/SOURCES.txt’
reading manifest file ‘/tmp/pip-modern-metadata-h3mth73v/onnx.egg-info/SOURCES.txt’
reading manifest template ‘MANIFEST.in’
writing manifest file ‘/tmp/pip-modern-metadata-h3mth73v/onnx.egg-info/SOURCES.txt’
creating ‘/tmp/pip-modern-metadata-h3mth73v/onnx.dist-info’
Traceback (most recent call last):
File “/home/xxxxxxxx/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py”, line 280, in
main()
File “/home/xxxxxxxx/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py”, line 263, in main
json_out[‘return_val’] = hook(**hook_input[‘kwargs’])
File “/home/xxxxxxxx/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py”, line 133, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File “/usr/local/lib/python3.6/dist-packages/setuptools/build_meta.py”, line 174, in prepare_metadata_for_build_wheel
self.run_setup()
File “/usr/local/lib/python3.6/dist-packages/setuptools/build_meta.py”, line 267, in run_setup
self).run_setup(setup_script=setup_script)
File “/usr/local/lib/python3.6/dist-packages/setuptools/build_meta.py”, line 158, in run_setup
exec(compile(code, file, ‘exec’), locals())
File “setup.py”, line 340, in
‘backend-test-tools = onnx.backend.test.cmd_tools:main’,
File “/usr/local/lib/python3.6/dist-packages/setuptools/init.py”, line 163, in setup
return distutils.core.setup(**attrs)
File “/usr/lib/python3.6/distutils/core.py”, line 148, in setup
dist.run_commands()
File “/usr/lib/python3.6/distutils/dist.py”, line 955, in run_commands
self.run_command(cmd)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/usr/local/lib/python3.6/dist-packages/setuptools/command/dist_info.py”, line 36, in run
bdist_wheel.egg2dist(egg_info.egg_info, dist_info_dir)
File “/usr/lib/python3/dist-packages/wheel/bdist_wheel.py”, line 443, in egg2dist
shutil.copy(license, os.path.join(self.distinfo_dir, license_filename))
File “/usr/lib/python3.6/posixpath.py”, line 80, in join
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
----------------------------------------
ERROR: Command errored out with exit status 1: /home/xxxxxxxx/venv/bin/python3 /home/xxxxxxxx/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp02z0d21i Check the logs for full command output.

Please help me with this issue.
Thanks!

Hi sparsh-b,

Please help to open a new topic for your issue. Thanks

Hello,

I had this issue as well it was solved with
sudo apt-get install protobuf-compiler libprotoc-dev
it seems that protobuf compiler is not installed by default. I hope this helps :-)

2 Likes