microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.87k stars 2.94k forks source link

[Build] /usr/bin/ld: failed to set dynamic section sizes: memory exhausted #22550

Closed vlasov01 closed 1 month ago

vlasov01 commented 1 month ago

Describe the issue

Unable to build onnxruntime on ubuntu 22 for armv7. During the last failed build I had 16GB of swap. Now I've doubled it.

#free
               total        used        free      shared  buff/cache   available
Mem:          505428      474592       10144          36       20692       19152
Swap:       33554428     2553600    31000828

Linux pynq 5.15.19-xilinx-v2022.1 #1 SMP PREEMPT Mon Apr 11 17:52:14 UTC 2022 armv7l armv7l armv7l GNU/Linux GNU ld (GNU Binutils for Ubuntu) 2.38 cmake version 3.31.20241016-gee2eadb

Urgency

No response

Target platform

armv7l

Build script

cd onnxruntime ./build.sh --config Release --parallel --skip_submodule_sync --skip_tests --use_xnnpack --build_wheel --cmake_extra_defines CMAKE_CXX_FLAGS="-Wno-dev -Wall -Wextra -O3 -g3 -mfloat-abi=hard -mfpu=neon-vfpv3 -mcpu=cortex-a9 -mfloat-abi=hard" CMAKE_C_FLAGS="-Wno-dev -Wall -Wextra -O3 -g3 -mfloat-abi=hard -mfpu=neon-vfpv3 -mcpu=cortex-a9 -mfloat-abi=hard"

Error / output

gmake[2]: [CMakeFiles/onnxruntime_pybind11_state.dir/build.make:205: CMakeFiles/onnxruntime_pybind11_state.dir/home/xilinx/onnxruntime/onnxruntime/python/onnxruntime_pybind_state.cc.o] Error 1 gmake[1]: [CMakeFiles/Makefile2:3127: CMakeFiles/onnxruntime_pybind11_state.dir/all] Error 2 gmake[1]: Waiting for unfinished jobs.... /usr/bin/ld: failed to set dynamic section sizes: memory exhausted collect2: error: ld returned 1 exit status gmake[2]: [CMakeFiles/onnxruntime_test_all.dir/build.make:5243: onnxruntime_test_all] Error 1 gmake[1]: [CMakeFiles/Makefile2:3334: CMakeFiles/onnxruntime_test_all.dir/all] Error 2 gmake: [Makefile:146: all] Error 2 Traceback (most recent call last): File "/home/xilinx/onnxruntime/tools/ci_build/build.py", line 2998, in sys.exit(main()) File "/home/xilinx/onnxruntime/tools/ci_build/build.py", line 2888, in main build_targets(args, cmake_path, build_dir, configs, num_parallel_jobs, args.target) File "/home/xilinx/onnxruntime/tools/ci_build/build.py", line 1739, in build_targets run_subprocess(cmd_args, env=env) File "/home/xilinx/onnxruntime/tools/ci_build/build.py", line 867, in run_subprocess return run(*args, cwd=cwd, capture_stdout=capture_stdout, shell=shell, env=my_env) File "/home/xilinx/onnxruntime/tools/python/util/run.py", line 49, in run completed_process = subprocess.run( File "/usr/lib/python3.10/subprocess.py", line 524, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['/usr/local/bin/cmake', '--build', '/home/xilinx/onnxruntime/build/Linux/Release', '--config', 'Release', '--', '-j2']' returned non-zero exit status 2.

Visual Studio Version

No response

GCC / Compiler Version

gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0

skottmckay commented 1 month ago

Typically building the main unit tests (onnxruntime_test_all) takes a huge amount of memory to link. You could try adding --skip_tests --cmake_extra_defines=onnxruntime_BUILD_UNIT_TESTS=OFF to avoid that.

vlasov01 commented 1 month ago

Thank you! I'm trying it now.

-- ******** Summary ********
--   CMake version                     : 3.31.20241016-gee2eadb
--   CMake command                     : /usr/local/bin/cmake
--   System                            : Linux
--   C++ compiler                      : /usr/bin/c++
--   C++ compiler version              : 11.2.0
--   CXX flags                         : -Wno-dev -Wall -Wextra -O3 -g3 -mfloat-abi=hard -mfpu=neon-vfpv3 -mcpu=cortex-a9 -mfloat-abi=hard -ffunction-sections -fdata-sections -Wno-restrict  -DCPUINFO_SUPPORTED -Wnon-virtual-dtor
--   Build type                        : Release
--   Compile definitions               : ORT_ENABLE_STREAM;EIGEN_MPL2_ONLY;_GNU_SOURCE;__STDC_FORMAT_MACROS
--   CMAKE_PREFIX_PATH                 : /home/xilinx/onnxruntime/build/Linux/Release/installed
--   CMAKE_INSTALL_PREFIX              : /usr/local
--   CMAKE_MODULE_PATH                 : /home/xilinx/onnxruntime/cmake/external
--
--   ONNX version                      : 1.16.1
--   ONNX NAMESPACE                    : onnx
--   ONNX_USE_LITE_PROTO               : ON
--   USE_PROTOBUF_SHARED_LIBS          : OFF
--   Protobuf_USE_STATIC_LIBS          : ON
--   ONNX_DISABLE_EXCEPTIONS           : OFF
--   ONNX_DISABLE_STATIC_REGISTRATION  : OFF
--   ONNX_WERROR                       : OFF
--   ONNX_BUILD_TESTS                  : OFF
--   ONNX_BUILD_BENCHMARKS             : OFF
--   ONNX_BUILD_SHARED_LIBS            :
--   BUILD_SHARED_LIBS                 : OFF
--
--   Protobuf compiler                 :
--   Protobuf includes                 :
--   Protobuf libraries                :
--   BUILD_ONNX_PYTHON                 : ON
-- Could NOT find Eigen3 (missing: Eigen3_DIR)
snnn commented 1 month ago

Use cross-compiling please. A 32-bit process can only use at most 2GB memory, which is not enough for a modern compiler.

vlasov01 commented 1 month ago

BUILD_UNIT_TESTS=OFF helped. But now I've got another error related to numpy as described in a closed issue https://github.com/microsoft/onnxruntime/issues/21145 .