Getting error as ERROR: Failed building wheel for onnx

Hi all, this is related to one of the sample python programs related to packnet from the directory
/usr/src/tensorrt/samples/python/onnx_packnet
As per the README.md I have executed the below statement
python3 -m pip install -r requirements.txt

and it gave the following error

ERROR: Failed building wheel for onnx
Failed to build onnx
ERROR: Could not build wheels for onnx, which is required to install pyproject.toml-based projects

Let me know how to install ONNX on the Jetson Nano board.

Hi,

We can install onnx with the below command:

$ pip3 install onnx

Thanks.

Hi, tried this but still got the same error which I posted earlier. Is there a way I can download the source code and build it from the source code itself, particularly on the jetson nano board.

Hi,

Just want to confirm.
Do you use Jetson Nano or Jetson Orin Nano?

The environment is quite different. Nano is Ubuntu 18.04+Python3.6 while Orin nano is 20.4 with Python 3.8.

Thanks.

It is Jetson Nano.

Thanks
Nagaraj Trivedi

Hi,

Please try this:

$ sudo apt-get install libprotobuf-dev protobuf-compiler

$ pip3 install setuptools==49.6.0
$ pip3 install cython==0.29.36
$ wget https://github.com/protocolbuffers/protobuf/releases/download/v3.5.1/protobuf-all-3.5.1.tar.gz
$ tar -xvzf protobuf-all-3.5.1.tar.gz 
$ cd protobuf-3.5.1/
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install
$ pip3 install onnx==1.12

Thanks.

Thank you for your help. But it failed at the last step
pip3 install onnx==1.12
Below are the logs of
pip3 install onnx==1.12
Defaulting to user installation because normal site-packages is not writeable
Collecting onnx==1.12
Using cached onnx-1.12.0.tar.gz (10.1 MB)
Preparing metadata (setup.py) … done
Requirement already satisfied: numpy>=1.16.6 in /home/mistral/.local/lib/python3.6/site-packages (from onnx==1.12) (1.19.4)
Requirement already satisfied: protobuf<=3.20.1,>=3.12.2 in /home/mistral/.local/lib/python3.6/site-packages (from onnx==1.12) (3.19.6)
Requirement already satisfied: typing-extensions>=3.6.2.1 in /home/mistral/.local/lib/python3.6/site-packages (from onnx==1.12) (4.1.1)
Building wheels for collected packages: onnx
Building wheel for onnx (setup.py) … error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/setup.py’“'”‘;f = getattr(tokenize, ‘"’“‘open’”’“‘, open)(file) if os.path.exists(file) else io.StringIO(’”‘“‘from setuptools import setup; setup()’”’“‘);code = f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ bdist_wheel -d /tmp/pip-wheel-kp4l5i6y
cwd: /tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/
Complete output (142 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
Using cmake args: [‘/usr/bin/cmake’, ‘-DPYTHON_INCLUDE_DIR=/usr/include/python3.6m’, ‘-DPYTHON_EXECUTABLE=/usr/bin/python3’, ‘-DBUILD_ONNX_PYTHON=ON’, ‘-DCMAKE_EXPORT_COMPILE_COMMANDS=ON’, ‘-DONNX_NAMESPACE=onnx’, ‘-DPY_EXT_SUFFIX=.cpython-36m-aarch64-linux-gnu.so’, ‘-DCMAKE_BUILD_TYPE=Release’, ‘-DONNX_ML=1’, ‘/tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244’]
– The C compiler identification is GNU 7.5.0
– The CXX compiler identification is GNU 7.5.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
– Found PythonInterp: /usr/bin/python3 (found version “3.6.9”)
– Found PythonLibs: /usr/lib/aarch64-linux-gnu/libpython3.6m.so (found version “3.6.9”)
– 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
/usr/local/bin/protoc: error while loading shared libraries: libprotoc.so.15: cannot open shared object file: No such file or directory
CMake Warning at /usr/share/cmake-3.10/Modules/FindProtobuf.cmake:455 (message):
Protobuf compiler version doesn’t match library version 3.5.1
Call Stack (most recent call first):
CMakeLists.txt:175 (find_package)

– Found Protobuf: /usr/local/lib/libprotobuf.so;-lpthread (found version “3.5.1”)
Generated: /tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/.setuptools-cmake-build/onnx/onnx-ml.proto
Generated: /tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/.setuptools-cmake-build/onnx/onnx-operators-ml.proto
Generated: /tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/.setuptools-cmake-build/onnx/onnx-data.proto
– Could NOT find pybind11 (missing: pybind11_DIR)
– pybind11 v2.9.1
– Found PythonLibs: /usr/lib/aarch64-linux-gnu/libpython3.6m.so
– Performing Test HAS_FLTO
– Performing Test HAS_FLTO - Success

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

– ONNX version : 1.12.0
– ONNX NAMESPACE : onnx
– ONNX_USE_LITE_PROTO : OFF
– USE_PROTOBUF_SHARED_LIBS : OFF
– Protobuf_USE_STATIC_LIBS : ON
– ONNX_DISABLE_EXCEPTIONS : OFF
– ONNX_WERROR : OFF
– ONNX_BUILD_TESTS : OFF
– ONNX_BUILD_BENCHMARKS : OFF
– ONNXIFI_DUMMY_BACKEND : OFF
– ONNXIFI_ENABLE_EXT : 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-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/.setuptools-cmake-build
Scanning dependencies of target gen_onnx_proto
Scanning dependencies of target onnxifi_loader
Scanning dependencies of target onnxifi_dummy
[ 1%] Running gen_proto.py on onnx/onnx.in.proto
[ 2%] Building C object CMakeFiles/onnxifi_loader.dir/onnx/onnxifi_loader.c.o
[ 4%] Building C object CMakeFiles/onnxifi_dummy.dir/onnx/onnxifi_dummy.c.o
[ 5%] Linking C static library libonnxifi_loader.a
Processing /tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/onnx/onnx.in.proto
Writing /tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/.setuptools-cmake-build/onnx/onnx-ml.proto
Writing /tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/.setuptools-cmake-build/onnx/onnx-ml.proto3
generating /tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/.setuptools-cmake-build/onnx/onnx_pb.py
[ 7%] Running C++ protocol buffer compiler on /tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/.setuptools-cmake-build/onnx/onnx-ml.proto
/usr/local/bin/protoc: error while loading shared libraries: libprotoc.so.15: cannot open shared object file: No such file or directory
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 127
CMakeFiles/Makefile2:178: 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…
[ 8%] Linking C shared library libonnxifi_dummy.so
[ 8%] Built target onnxifi_loader
[ 8%] 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-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/setup.py”, line 354, in
“backend-test-tools = onnx.backend.test.cmd_tools:main”,
File “/home/mistral/.local/lib/python3.6/site-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/wheel/bdist_wheel.py”, line 299, 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-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/setup.py”, line 223, 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-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/setup.py”, line 217, 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 io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/setup.py’“'”‘;f = getattr(tokenize, ‘"’“‘open’”’“‘, open)(file) if os.path.exists(file) else io.StringIO(’”‘“‘from setuptools import setup; setup()’”’“‘);code = f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ install --record /tmp/pip-record-m7lny0hg/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/mistral/.local/include/python3.6m/onnx
cwd: /tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/
Complete output (107 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
Using cmake args: [‘/usr/bin/cmake’, ‘-DPYTHON_INCLUDE_DIR=/usr/include/python3.6m’, ‘-DPYTHON_EXECUTABLE=/usr/bin/python3’, ‘-DBUILD_ONNX_PYTHON=ON’, ‘-DCMAKE_EXPORT_COMPILE_COMMANDS=ON’, ‘-DONNX_NAMESPACE=onnx’, ‘-DPY_EXT_SUFFIX=.cpython-36m-aarch64-linux-gnu.so’, ‘-DCMAKE_BUILD_TYPE=Release’, ‘-DONNX_ML=1’, ‘/tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244’]
/usr/local/bin/protoc: error while loading shared libraries: libprotoc.so.15: cannot open shared object file: No such file or directory
CMake Warning at /usr/share/cmake-3.10/Modules/FindProtobuf.cmake:455 (message):
Protobuf compiler version doesn’t match library version 3.5.1
Call Stack (most recent call first):
CMakeLists.txt:175 (find_package)

Generated: /tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/.setuptools-cmake-build/onnx/onnx-ml.proto
Generated: /tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/.setuptools-cmake-build/onnx/onnx-operators-ml.proto
Generated: /tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/.setuptools-cmake-build/onnx/onnx-data.proto
-- Could NOT find pybind11 (missing: pybind11_DIR)
-- pybind11 v2.9.1
--
-- ******** Summary ********
--   CMake version             : 3.10.2
--   CMake command             : /usr/bin/cmake
--   System                    : Linux
--   C++ compiler              : /usr/bin/c++
--   C++ compiler version      : 7.5.0
--   CXX flags                 :  -Wnon-virtual-dtor
--   Build type                : Release
--   Compile definitions       : __STDC_FORMAT_MACROS
--   CMAKE_PREFIX_PATH         :
--   CMAKE_INSTALL_PREFIX      : /usr/local
--   CMAKE_MODULE_PATH         :
--
--   ONNX version              : 1.12.0
--   ONNX NAMESPACE            : onnx
--   ONNX_USE_LITE_PROTO       : OFF
--   USE_PROTOBUF_SHARED_LIBS  : OFF
--   Protobuf_USE_STATIC_LIBS  : ON
--   ONNX_DISABLE_EXCEPTIONS   : OFF
--   ONNX_WERROR               : OFF
--   ONNX_BUILD_TESTS          : OFF
--   ONNX_BUILD_BENCHMARKS     : OFF
--   ONNXIFI_DUMMY_BACKEND     : OFF
--   ONNXIFI_ENABLE_EXT        : 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-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/.setuptools-cmake-build
[  1%] Running C++ protocol buffer compiler on /tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/.setuptools-cmake-build/onnx/onnx-ml.proto
[  4%] Built target onnxifi_dummy
[  7%] Built target onnxifi_loader
/usr/local/bin/protoc: error while loading shared libraries: libprotoc.so.15: cannot open shared object file: No such file or directory
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 127
CMakeFiles/Makefile2:178: 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....
Scanning dependencies of target onnxifi_wrapper
[  8%] Building C object CMakeFiles/onnxifi_wrapper.dir/onnx/onnxifi_wrapper.c.o
[  9%] Linking C shared module libonnxifi.so
[  9%] Built target onnxifi_wrapper
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/setup.py", line 354, in <module>
    "backend-test-tools = onnx.backend.test.cmd_tools:main",
  File "/home/mistral/.local/lib/python3.6/site-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 "/home/mistral/.local/lib/python3.6/site-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-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/setup.py", line 223, 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-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/setup.py", line 217, 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 io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-9yqugubt/onnx_5e29dea78236434ba23c375e9eeaf244/setup.py’“'”‘;f = getattr(tokenize, ‘"’“‘open’”’“‘, open)(file) if os.path.exists(file) else io.StringIO(’”‘“‘from setuptools import setup; setup()’”’“‘);code = f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ install --record /tmp/pip-record-m7lny0hg/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/mistral/.local/include/python3.6m/onnx Check the logs for full command output.

Hi,

Could you remove the protobuf-compiler package and try the instructions above again?

$ sudo apt remove protobuf-compiler

Thanks.

Hi, it worked. Thank you for your help.

Thanks and Regards

Nagaraj Trivedi

Hey!
I am facing the same issue and I am working on Jetson Xavier NX Development Kit

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