Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during compiling rel-1.5.3 natively on ARM64 (Ubuntu 20.10 aarch64) #5987

Closed
vak opened this issue Dec 1, 2020 · 11 comments
Closed

Error during compiling rel-1.5.3 natively on ARM64 (Ubuntu 20.10 aarch64) #5987

vak opened this issue Dec 1, 2020 · 11 comments
Labels
contributions welcome external contributions welcome core runtime issues related to core runtime

Comments

@vak
Copy link

vak commented Dec 1, 2020

Describe the bug
During the native compilation of onnxruntime on Linux ARM64 device the following error appears:

nlohmann/json.hpp:8494:24: error: comparison is always true due to limited range of data type [-Werror=type-limits]

Urgency
middle

System information

  • ARM64 (Raspberry Pi 4B)
  • Ubuntu 20.10 (aarch64)
  • ONNX Runtime failed to compile from sources
  • ONNX Runtime version: 1.5.3
  • Python version: 3.8.6
  • Visual Studio version (if applicable): N/A
  • GCC/Compiler version (if compiling from source): gcc (Ubuntu 10.2.0-13ubuntu1) 10.2.0
  • CUDA/cuDNN version: N/A
  • GPU model and memory: N/A

To Reproduce

git clone --branch rel-1.5.3 --recursive https://github.com/Microsoft/onnxruntime
cd onnxruntime
./build.sh --config MinSizeRel --update --build

BTW, and as of today it is the same without --branch rel-1.5.3, i.e. on master branch.

Expected behavior
compilation should succeed ;-)

Screenshots

[ 54%] Building CXX object CMakeFiles/onnxruntime_session.dir/home/dev/dev/onnxruntime/onnxruntime/core/session/inference_session.cc.o
In file included from /home/dev/dev/onnxruntime/onnxruntime/core/session/inference_session_utils.h:21,
                 from /home/dev/dev/onnxruntime/onnxruntime/core/session/inference_session.cc:47:
/home/dev/dev/onnxruntime/cmake/external/json/single_include/nlohmann/json.hpp: In instantiation of ‘std::string nlohmann::detail::lexer<BasicJsonType>::get_token_string() const [with BasicJsonType = nlohmann::basic_json<>; std::string = std::__cxx11::basic_string<char>]’:
/home/dev/dev/onnxruntime/cmake/external/json/single_include/nlohmann/json.hpp:8745:57:   required from ‘void nlohmann::detail::parser<BasicJsonType>::parse(bool, BasicJsonType&) [with BasicJsonType = nlohmann::basic_json<>]’
/home/dev/dev/onnxruntime/cmake/external/json/single_include/nlohmann/json.hpp:20835:79:   required from ‘static nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parse(IteratorType, IteratorType, nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser_callback_t, bool) [with IteratorType = const char*; typename std::enable_if<std::is_base_of<std::random_access_iterator_tag, typename std::iterator_traits<_InputIterator>::iterator_category>::value, int>::type <anonymous> = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser_callback_t = std::function<bool(int, nlohmann::detail::parser<nlohmann::basic_json<> >::parse_event_t, nlohmann::basic_json<>&)>]’
/home/dev/dev/onnxruntime/cmake/external/json/single_include/nlohmann/json.hpp:22653:42:   required from here
/home/dev/dev/onnxruntime/cmake/external/json/single_include/nlohmann/json.hpp:8494:24: error: comparison is always true due to limited range of data type [-Werror=type-limits]
 8494 |             if ('\x00' <= c and c <= '\x1F')
      |                 ~~~~~~~^~~~
cc1plus: all warnings being treated as errors
gmake[2]: *** [CMakeFiles/onnxruntime_session.dir/build.make:141: CMakeFiles/onnxruntime_session.dir/home/dev/dev/onnxruntime/onnxruntime/core/session/inference_session.cc.o] Error 1
gmake[2]: Leaving directory '/home/dev/dev/onnxruntime/build/Linux/MinSizeRel'
gmake[1]: *** [CMakeFiles/Makefile2:744: CMakeFiles/onnxruntime_session.dir/all] Error 2
gmake[1]: Leaving directory '/home/dev/dev/onnxruntime/build/Linux/MinSizeRel'
gmake: *** [Makefile:163: all] Error 2
Traceback (most recent call last):
  File "/home/dev/dev/onnxruntime/tools/ci_build/build.py", line 1794, in <module>
    sys.exit(main())
  File "/home/dev/dev/onnxruntime/tools/ci_build/build.py", line 1732, in main
    build_targets(args, cmake_path, build_dir, configs, args.parallel, args.target)
  File "/home/dev/dev/onnxruntime/tools/ci_build/build.py", line 943, in build_targets
    run_subprocess(cmd_args, env=env)
  File "/home/dev/dev/onnxruntime/tools/ci_build/build.py", line 432, in run_subprocess
    completed_process = subprocess.run(
  File "/usr/lib/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/cmake', '--build', '/home/dev/dev/onnxruntime/build/Linux/MinSizeRel', '--config', 'MinSizeRel']' returned non-zero exit status 2.

Additional context
Similar or same error:
nlohmann/json#1939
nlohmann/json#1940

Perhaps a newer version of json library should be used?

@snnn
Copy link
Member

snnn commented Dec 1, 2020

Would the latest 3.9.1 release solve the issue?

@snnn snnn added the core runtime issues related to core runtime label Dec 1, 2020
@vak
Copy link
Author

vak commented Dec 2, 2020

I was able to bypass this error using master branch of the respective json submodule in cmake/exetarnal/json. To succeed in this, one should also drop --update to avoid reverting back to json 3.7.1

So, I guess, 3.9.1 release of json should do the job as well. This error patch was applied around June there.

@vak
Copy link
Author

vak commented Dec 2, 2020

@snnn
unfortunately ./build.sh --config MinSizeRel --build_shared_lib reverses the json during unwanted update, albeit as you see, --update isn't provided.

@vak
Copy link
Author

vak commented Dec 2, 2020

ah, got it: --skip_submodule_sync

@snnn snnn added the contributions welcome external contributions welcome label Dec 2, 2020
@vak
Copy link
Author

vak commented Dec 8, 2020

@snnn, I was able to build and install the .whl library. However if I try to import it i am getting this error:

% python3
Python 3.8.6 (default, Sep 25 2020, 09:36:53) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import onnxruntime
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dev/dev/onnxruntime/onnxruntime/__init__.py", line 13, in <module>
    from onnxruntime.capi._pybind_state import get_all_providers, get_available_providers, get_device, set_seed, \
ModuleNotFoundError: No module named 'onnxruntime.capi'
dev@c7843bb6adbf:~/.local/lib/python3.8/site-packages/onnxruntime/capi$ ls -l
total 9696
drwxrwxr-x 4 dev dev    4096 Dec  8 12:13 ./
drwxrwxr-x 9 dev dev    4096 Dec  8 12:13 ../
-rw-rw-r-- 1 dev dev     247 Dec  8 12:13 __init__.py
drwxrwxr-x 2 dev dev    4096 Dec  8 12:13 __pycache__/
-rw-rw-r-- 1 dev dev     477 Dec  8 12:13 _ld_preload.py
-rw-rw-r-- 1 dev dev    1478 Dec  8 12:13 _pybind_state.py
-rwxrwxr-x 1 dev dev 9879328 Dec  8 12:13 onnxruntime_pybind11_state.so*
-rw-rw-r-- 1 dev dev    2737 Dec  8 12:13 onnxruntime_validation.py
-rw-rw-r-- 1 dev dev   12927 Dec  8 12:13 session.py
drwxrwxr-x 3 dev dev    4096 Dec  8 12:13 training/
dev@c7843bb6adbf:~/.local/lib/python3.8/site-packages/onnxruntime/capi$ rgrep get_device
Binary file onnxruntime_pybind11_state.so matches
dev@c7843bb6adbf:~/.local/lib/python3.8/site-packages/onnxruntime/capi$

do you have an idea how to fix this error?

@darkfloyd01-117
Copy link

@snnn, I was able to build and install the .whl library. However if I try to import it i am getting this error:

% python3
Python 3.8.6 (default, Sep 25 2020, 09:36:53) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import onnxruntime
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dev/dev/onnxruntime/onnxruntime/__init__.py", line 13, in <module>
    from onnxruntime.capi._pybind_state import get_all_providers, get_available_providers, get_device, set_seed, \
ModuleNotFoundError: No module named 'onnxruntime.capi'
dev@c7843bb6adbf:~/.local/lib/python3.8/site-packages/onnxruntime/capi$ ls -l
total 9696
drwxrwxr-x 4 dev dev    4096 Dec  8 12:13 ./
drwxrwxr-x 9 dev dev    4096 Dec  8 12:13 ../
-rw-rw-r-- 1 dev dev     247 Dec  8 12:13 __init__.py
drwxrwxr-x 2 dev dev    4096 Dec  8 12:13 __pycache__/
-rw-rw-r-- 1 dev dev     477 Dec  8 12:13 _ld_preload.py
-rw-rw-r-- 1 dev dev    1478 Dec  8 12:13 _pybind_state.py
-rwxrwxr-x 1 dev dev 9879328 Dec  8 12:13 onnxruntime_pybind11_state.so*
-rw-rw-r-- 1 dev dev    2737 Dec  8 12:13 onnxruntime_validation.py
-rw-rw-r-- 1 dev dev   12927 Dec  8 12:13 session.py
drwxrwxr-x 3 dev dev    4096 Dec  8 12:13 training/
dev@c7843bb6adbf:~/.local/lib/python3.8/site-packages/onnxruntime/capi$ rgrep get_device
Binary file onnxruntime_pybind11_state.so matches
dev@c7843bb6adbf:~/.local/lib/python3.8/site-packages/onnxruntime/capi$

do you have an idea how to fix this error?

I am getting same error. Any help would be appreciated.

@vak Thank you for your detailed instruction. I was able to get a successful build on Raspberry PI4.

@darkfloyd01-117
Copy link

I was able to fix that issue. As described in 2133#issuecomment-542837394 I was getting that error because I was trying to import onnxruntime from source directory.

I manually installed generated whl file and that fixed the issue.

aaa77707@desktop:~/onnxruntime$ find ./ -name *.whl
./build/Linux/MinSizeRel/dist/onnxruntime-1.5.3-cp38-cp38-linux_aarch64.whl

aaa77707@desktop:~/onnxruntime$ pip3 install ./build/Linux/MinSizeRel/dist/onnxruntime-1.5.3-cp38-cp38-linux_aarch64.whl

@snnn
Copy link
Member

snnn commented Dec 29, 2020

So, we should update nlohmann/json to the latest?

@vak
Copy link
Author

vak commented Jan 5, 2021

@snnn, oh, yes, please.

@snnn
Copy link
Member

snnn commented Aug 18, 2021

So, we should update nlohmann/json to the latest?

#7985

@snnn snnn closed this as completed Aug 18, 2021
@anu-n87
Copy link

anu-n87 commented Jan 4, 2023

I tried installing nlohmann json and some files found missing in /usr/include/nlohmann. I used sudo apt-get install nlohmann-json3-dev for installation and it was success. However some files are missing which I use in my code and hence the code is having compilation issues. I tried copying those files from other system. But it did not work. My system details:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal
Architecture is arm64.
Can anyone please help to get it resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions welcome external contributions welcome core runtime issues related to core runtime
Projects
None yet
Development

No branches or pull requests

4 participants