question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build onnx arm32 with protobuf permission error

See original GitHub issue

Bug Report

fail to build onnx into python wheel with error snippet:

[ 98%] Linking CXX shared module onnx_cpp2py_export.cpython-37m-arm-linux-gnueabihf.so
/usr/bin/ld: /usr/lib/arm-linux-gnueabihf/libprotobuf.a(arena.o)(.text+0x7cc): R_ARM_TLS_LE32 relocation not permitted in shared object

Is the issue related to model conversion?

No.

Describe the bug

build failure

System information

  • OS Platform and Distribution (e.g. Linux Ubuntu 16.04): Linux Ubuntu 22.04 (jammy)
  • ONNX version (e.g. 1.7): 1.10
  • Python version: 3.7
  • GCC/Compiler version (if compiling from source): 11.2.0 (apt-get)
  • CMake version: 3.22.1 (apt-get)
  • Protobuf version: 3.12.4 (apt-get)
  • Visual Studio version (if applicable): n/a

Some information:

Using cmake args: ['/usr/bin/cmake', '-DPYTHON_INCLUDE_DIR=/usr/local/include/python3.7m', '-DPYTHON_EXECUTABLE=/usr/local/bin/python3', '-DBUILD_ONNX_PYTHON=ON', '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON', '-DONNX_NAMESPACE=onnx', '-DPY_EXT_SUFFIX=.cpython-37m-arm-linux-gnueabihf.so', '-DCMAKE_BUILD_TYPE=Release', '-DONNX_ML=1', '/code/onnx']
Generated: /code/onnx/.setuptools-cmake-build/onnx/onnx-ml.proto
Generated: /code/onnx/.setuptools-cmake-build/onnx/onnx-operators-ml.proto
Generated: /code/onnx/.setuptools-cmake-build/onnx/onnx-data.proto
-- Found pybind11: /usr/local/lib/python3.7/site-packages/pybind11/include (found version "2.9.2")
-- 
-- ******** Summary ********
--   CMake version             : 3.22.1
--   CMake command             : /usr/bin/cmake
--   System                    : Linux
--   C++ compiler              : /usr/bin/c++
--   C++ compiler version      : 11.2.0
--   CXX flags                 :  -Wnon-virtual-dtor
--   Build type                : Release
--   Compile definitions       : 
--   CMAKE_PREFIX_PATH         : 
--   CMAKE_INSTALL_PREFIX      : /usr/local
--   CMAKE_MODULE_PATH         : 
-- 
--   ONNX version              : 1.10.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/bin/protoc
--   Protobuf includes         : /usr/include
--   Protobuf libraries        : /usr/lib/arm-linux-gnueabihf/libprotobuf.a
--   BUILD_ONNX_PYTHON         : ON
--     Python version        : 
--     Python executable     : /usr/local/bin/python3
--     Python includes       : /usr/local/include/python3.7m
-- Configuring done
-- Generating done

The installed protobuf lib:

root@4a00714193b1:/code/onnx# ls -la /usr/lib/arm-linux-gnueabihf/libproto*
-rw-r--r-- 1 root root 1234380 Mar 17 19:36 /usr/lib/arm-linux-gnueabihf/libprotobuf-lite.a
lrwxrwxrwx 1 root root      26 Mar 17 19:36 /usr/lib/arm-linux-gnueabihf/libprotobuf-lite.so -> libprotobuf-lite.so.23.0.4
lrwxrwxrwx 1 root root      26 Mar 17 19:36 /usr/lib/arm-linux-gnueabihf/libprotobuf-lite.so.23 -> libprotobuf-lite.so.23.0.4
-rw-r--r-- 1 root root  485592 Mar 17 19:36 /usr/lib/arm-linux-gnueabihf/libprotobuf-lite.so.23.0.4
-rwxrwxrwx 1 root root 5179258 Mar 17 19:36 /usr/lib/arm-linux-gnueabihf/libprotobuf.a
lrwxrwxrwx 1 root root      21 Mar 17 19:36 /usr/lib/arm-linux-gnueabihf/libprotobuf.so -> libprotobuf.so.23.0.4
lrwxrwxrwx 1 root root      21 Mar 17 19:36 /usr/lib/arm-linux-gnueabihf/libprotobuf.so.23 -> libprotobuf.so.23.0.4
-rw-r--r-- 1 root root 2049608 Mar 17 19:36 /usr/lib/arm-linux-gnueabihf/libprotobuf.so.23.0.4
lrwxrwxrwx 1 root root      19 Mar 17 19:36 /usr/lib/arm-linux-gnueabihf/libprotoc.so.23 -> libprotoc.so.23.0.4
-rw-r--r-- 1 root root 1929184 Mar 17 19:36 /usr/lib/arm-linux-gnueabihf/libprotoc.so.23.0.4

apt list:

root@4a00714193b1:/code/onnx# apt list --installed

cmake/jammy,now 3.22.1-1ubuntu1 armhf [installed]
...
libprotobuf-dev/jammy,now 3.12.4-1ubuntu7 armhf [installed]
libprotobuf-lite23/jammy,now 3.12.4-1ubuntu7 armhf [installed,automatic]
libprotobuf23/jammy,now 3.12.4-1ubuntu7 armhf [installed,automatic]
libprotoc23/jammy,now 3.12.4-1ubuntu7 armhf [installed,automatic]

Reproduction instructions

The command to build:

git clone --single-branch --branch v1.10.0 https://github.com/onnx/onnx
cd onnx
python3 setup.py bdist_wheel

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
zoldatencommented, Aug 11, 2022

ok. solved. that was a setuptools issue. the last command should be: python3 -m pip install not: pip install -e .

moreover i installed pybind11: pip install "pybind11[global]"

and finally i got import error:

pi@raspberrypi:~/onnx $ python -c "import onnx"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/pi/onnx/onnx/__init__.py", line 6, in <module>
    from .onnx_cpp2py_export import ONNX_ML
ImportError: cannot import name 'ONNX_ML' from 'onnx.onnx_cpp2py_export' (unknown location)

which should be fixed by add to ~/.bashrc (sudo nano ~/.bashrc): export LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1

and reread ~/.bashrc: source ~/.bashrc

0reactions
zoldatencommented, Aug 11, 2022

It seems like an issue in Python. What’s your Python version? The latest main branch of ONNX is guaranteed to support Python 3.7-3.10. IIUC, f-strings in Python was introduced after Python 3.6.

python 3.7.3

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Cross-Compile ArmNN on x86_64 for arm64
This build flow has been tested with Ubuntu 16.04. The instructions show how to build the ArmNN core library and the Boost, Protobuf,...
Read more >
[Arm NN on Cortex-A9] Static build leads to "None of the ...
I have been able to build a STATIC version of libarmnn. ... to "None of the preferred backends [CpuRef ] are supported" error...
Read more >
Configuring the Arm NN SDK Build Environment for ONNX - NET
THIS DOCUMENT IS PROVIDED “AS IS”. ARM PROVIDES NO REPRESENTATIONS AND NO WARRANTIES, EXPRESS, IMPLIED. OR STATUTORY, INCLUDING ...
Read more >
Release 1.22.0 - ONE(On-device Neural Engine)
To cross build, infra/nncc/Makefile.arm32 file is provided as an example to ... /sbin/ldconfig: Cannot lstat /lib64/libhdf5.so.101.0.0: Permission denied.
Read more >
EPEL 8 for x86_64 - RPMFind
Build.Framework · 12.0.0.0__b03f5f7f11d50a3a · 14.0.0.0__b03f5f7f11d50a3a · 4.0.0.0__b03f5f7f11d50a3a · Microsoft.Build.Tasks.Core.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found