難しいonnxtuntimeソースコードのコンパイルプロセスを記録する

1.まず、onnxruntimeソースコードをダウンロードします

送信元アドレス:onnxruntime

# 必须--recursive, 否则很多库文件下载不齐
git clone --recursive https://github.com/microsoft/onnxruntime.git

コンパイルエラーのほとんどの理由は、git cloneがダウンロードされておらず、多くのgitがネストされているため、再帰的なダウンロードが必要になることです。
ここに画像の説明を挿入します

2.ソースコードのコンパイル

WindowsでWSL2(docker)を使用してコンパイルしましたが、WindowsでWindowsターミナルを使用できませんでした。

Makefile:162: recipe for target 'all' failed make: *** [all] Error 2

後で私はMobaXtream、魔法、ブームを使いました!パスをコンパイルする

sudo apt-get install -y libgomp1
sudo apt install zlib1g-dev
sudo apt-get install -y locales
sudo apt-get install -y language-pack-en
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8
# --build_shared_lib会在build/Release/linux生成动态链接库so
./build.sh --skip_submodule_sync --build_shared_lib --use_openmp --config Release --build_wheel --update --build --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER)

# 不是用openmp
./build.sh --skip_submodule_sync --build_shared_lib --config Release --build_wheel --update --build --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER)

adding 'onnxruntime-1.7.0.data/purelib/onnxruntime/transformers/onnx_model_bert_keras.py'
adding 'onnxruntime-1.7.0.data/purelib/onnxruntime/transformers/onnx_model_bert_tf.py'
adding 'onnxruntime-1.7.0.data/purelib/onnxruntime/transformers/onnx_model_gpt2.py'
adding 'onnxruntime-1.7.0.data/purelib/onnxruntime/transformers/optimizer.py'
adding 'onnxruntime-1.7.0.data/purelib/onnxruntime/transformers/parity_check_helper.py'
adding 'onnxruntime-1.7.0.data/purelib/onnxruntime/transformers/profiler.py'
adding 'onnxruntime-1.7.0.data/purelib/onnxruntime/transformers/quantize_helper.py'
adding 'onnxruntime-1.7.0.data/purelib/onnxruntime/transformers/shape_optimizer.py'
adding 'onnxruntime-1.7.0.data/purelib/onnxruntime/transformers/longformer/__init__.py'
adding 'onnxruntime-1.7.0.data/purelib/onnxruntime/transformers/longformer/benchmark_longformer.py'
adding 'onnxruntime-1.7.0.data/purelib/onnxruntime/transformers/longformer/convert_longformer_to_onnx.py'
adding 'onnxruntime-1.7.0.data/purelib/onnxruntime/transformers/longformer/generate_test_data.py'
adding 'onnxruntime-1.7.0.data/purelib/onnxruntime/transformers/longformer/longformer_helper.py'
adding 'onnxruntime-1.7.0.dist-info/DESCRIPTION.rst'
adding 'onnxruntime-1.7.0.dist-info/entry_points.txt'
adding 'onnxruntime-1.7.0.dist-info/metadata.json'
adding 'onnxruntime-1.7.0.dist-info/top_level.txt'
adding 'onnxruntime-1.7.0.dist-info/WHEEL'
adding 'onnxruntime-1.7.0.dist-info/METADATA'
adding 'onnxruntime-1.7.0.dist-info/RECORD'
2021-03-07 11:56:31,618 util.run [DEBUG] - Subprocess completed. Return code: 0
2021-03-07 11:56:31,618 build [INFO] - Build complete

root@665df1042110:/mnt/g/src/inference/OnnxRT/onnxruntime/build/Linux/Release# ls
CMakeCache.txt                 onnxruntime_test_all
CMakeFiles                     onnxruntime_test_ort_trainer.py
CPackConfig.cmake              onnxruntime_test_ort_trainer_with_mixed_precision.py
CPackSourceConfig.cmake        onnxruntime_test_postprocess.py
CTestTestfile.cmake            onnxruntime_test_python.py
DartConfiguration.tcl          onnxruntime_test_python_backend.py
Makefile                       onnxruntime_test_python_backend_mlops.py
Testing                        onnxruntime_test_python_iobinding.py
VERSION_NUMBER                 onnxruntime_test_python_keras.py
_test_commons.py               onnxruntime_test_python_mlops.py
_test_helpers.py               onnxruntime_test_python_nuphar.py
bin                            onnxruntime_test_python_symbolic_shape_infer.py
build                          onnxruntime_test_training_unit_tests.py
checkpoint                     onnxruntime_test_training_unittest_utils.py
cmake_install.cmake            orttraining_distributed_tests.py
compile_commands.json          orttraining_run_bert_pretrain.py
dhp_parallel                   orttraining_run_frontend_batch_size_test.py
dist                           orttraining_run_glue.py
external                       orttraining_run_multiple_choice.py
helper.py                      orttraining_test_allreduce.py
launch_test.py                 orttraining_test_allreduce_adasum.py
lib                            orttraining_test_bert_postprocess.py
libcustom_op_library.so        orttraining_test_checkpoint.py
libonnx_test_data_proto.a      orttraining_test_checkpoint_storage.py
libonnx_test_runner_common.a   orttraining_test_data_loader.py
libonnxruntime_common.a        orttraining_test_debuggability.py
libonnxruntime_flatbuffers.a   orttraining_test_dhp_parallel_tests.py
libonnxruntime_framework.a     orttraining_test_layer_norm_transform.py
libonnxruntime_graph.a         orttraining_test_model_transform.py
libonnxruntime_mlas.a          orttraining_test_orttrainer_bert_toy_onnx.py
libonnxruntime_optimizer.a     orttraining_test_orttrainer_checkpoint_functions.py
libonnxruntime_providers.a     orttraining_test_orttrainer_frontend.py
libonnxruntime_session.a       orttraining_test_transformers.py
libonnxruntime_test_utils.a    orttraining_test_utils.py
libonnxruntime_util.a          orttraining_transformer_trainer.py
onnx_backend_test_series.py    pybind11
onnx_test_runner               quantization
onnxruntime                    samples
onnxruntime.egg-info           testdata
onnxruntime_config.h           tml.pb.cc
onnxruntime_mlas_test          tml.pb.h
onnxruntime_perf_test          utils_multiple_choice.py
onnxruntime_pybind11_state.so

インストールする

root@665df1042110:/mnt/g/src/inference/OnnxRT/onnxruntime/build/Linux/Release# make install

/ usr / local / include / onnxruntime /に正常にインストールされました

[  0%] Built target flatbuffers
[  8%] Built target libprotobuf
[ 16%] Built target libprotoc
[ 16%] Built target protoc
[ 17%] Built target gen_onnx_proto
[ 20%] Built target libprotobuf-lite
[ 21%] Built target onnx_proto
[ 25%] Built target flatc
[ 25%] Built target onnxruntime_flatbuffers
[ 31%] Built target onnxruntime_mlas
[ 36%] Built target onnx
[ 53%] Built target onnxruntime_providers
[ 54%] Built target onnxruntime_graph
[ 55%] Built target onnxruntime_test_utils
[ 55%] Built target onnx_test_data_proto
[ 60%] Built target onnxruntime_optimizer
[ 62%] Built target onnxruntime_common
[ 62%] Built target onnxruntime_util
[ 63%] Built target onnx_test_runner_common
[ 69%] Built target onnxruntime_framework
[ 70%] Built target onnxruntime_session
[ 73%] Built target nsync_cpp
[ 76%] Built target re2
[ 76%] Built target onnxruntime_perf_test
[ 76%] Built target onnx_test_runner
[ 76%] Built target gtest
[ 76%] Built target gmock
[ 98%] Built target onnxruntime_test_all
[ 98%] Built target onnxruntime_mlas_test
[ 98%] Performing update step for 'pybind11'
[ 98%] No configure step for 'pybind11'
[ 98%] No build step for 'pybind11'
[ 98%] No install step for 'pybind11'
[ 98%] Completed 'pybind11'
[100%] Built target pybind11
[100%] Built target custom_op_library
[100%] Built target onnxruntime_pybind11_state
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/include/onnxruntime/core/common
-- Installing: /usr/local/include/onnxruntime/core/common/code_location.h
-- Installing: /usr/local/include/onnxruntime/core/common/common.h
-- Installing: /usr/local/include/onnxruntime/core/common/const_pointer_container.h
-- Installing: /usr/local/include/onnxruntime/core/common/denormal.h
-- Installing: /usr/local/include/onnxruntime/core/common/eigen_common_wrapper.h
-- Installing: /usr/local/include/onnxruntime/core/common/exceptions.h
-- Installing: /usr/local/include/onnxruntime/core/common/logging
-- Installing: /usr/local/include/onnxruntime/core/common/logging/capture.h
-- Installing: /usr/local/include/onnxruntime/core/common/logging/isink.h
-- Installing: /usr/local/include/onnxruntime/core/common/logging/logging.h
-- Installing: /usr/local/include/onnxruntime/core/common/logging/macros.h
-- Installing: /usr/local/include/onnxruntime/core/common/logging/severity.h
-- Installing: /usr/local/include/onnxruntime/core/common/make_string.h
-- Installing: /usr/local/include/onnxruntime/core/common/make_unique.h
-- Installing: /usr/local/include/onnxruntime/core/common/optional.h
-- Installing: /usr/local/include/onnxruntime/core/common/parse_string.h
-- Installing: /usr/local/include/onnxruntime/core/common/spin_pause.h
-- Installing: /usr/local/include/onnxruntime/core/common/status.h
-- Installing: /usr/local/include/onnxruntime/core/graph
-- Installing: /usr/local/include/onnxruntime/core/graph/basic_types.h
-- Installing: /usr/local/include/onnxruntime/core/graph/constants.h
-- Installing: /usr/local/include/onnxruntime/core/graph/function.h
-- Installing: /usr/local/include/onnxruntime/core/graph/graph.h
-- Installing: /usr/local/include/onnxruntime/core/graph/graph_nodes.h
-- Installing: /usr/local/include/onnxruntime/core/graph/graph_viewer.h
-- Installing: /usr/local/include/onnxruntime/core/graph/indexed_sub_graph.h
-- Installing: /usr/local/include/onnxruntime/core/graph/node_arg.h
-- Installing: /usr/local/include/onnxruntime/core/graph/onnx_protobuf.h
-- Installing: /usr/local/include/onnxruntime/core/graph/schema_registry.h
-- Installing: /usr/local/include/onnxruntime/core/framework
-- Installing: /usr/local/include/onnxruntime/core/framework/allocator.h
-- Installing: /usr/local/include/onnxruntime/core/framework/alloc_kind.h
-- Installing: /usr/local/include/onnxruntime/core/framework/customregistry.h
-- Installing: /usr/local/include/onnxruntime/core/framework/data_types.h
-- Installing: /usr/local/include/onnxruntime/core/framework/data_types_internal.h
-- Installing: /usr/local/include/onnxruntime/core/framework/endian.h
-- Installing: /usr/local/include/onnxruntime/core/framework/execution_provider.h
-- Installing: /usr/local/include/onnxruntime/core/framework/fence.h
-- Installing: /usr/local/include/onnxruntime/core/framework/float16.h
-- Installing: /usr/local/include/onnxruntime/core/framework/framework_common.h
-- Installing: /usr/local/include/onnxruntime/core/framework/func_api.h
-- Installing: /usr/local/include/onnxruntime/core/framework/kernel_def_builder.h
-- Installing: /usr/local/include/onnxruntime/core/framework/kernel_registry.h
-- Installing: /usr/local/include/onnxruntime/core/framework/ml_value.h
-- Installing: /usr/local/include/onnxruntime/core/framework/op_kernel.h
-- Installing: /usr/local/include/onnxruntime/core/framework/op_kernel_context.h
-- Installing: /usr/local/include/onnxruntime/core/framework/op_kernel_info.h
-- Installing: /usr/local/include/onnxruntime/core/framework/op_node_proto_helper.h
-- Installing: /usr/local/include/onnxruntime/core/framework/ortdevice.h
-- Installing: /usr/local/include/onnxruntime/core/framework/ortmemoryinfo.h
-- Installing: /usr/local/include/onnxruntime/core/framework/provider_options.h
-- Installing: /usr/local/include/onnxruntime/core/framework/provider_options_utils.h
-- Installing: /usr/local/include/onnxruntime/core/framework/provider_shutdown.h
-- Installing: /usr/local/include/onnxruntime/core/framework/run_options.h
-- Installing: /usr/local/include/onnxruntime/core/framework/sparse_tensor.h
-- Installing: /usr/local/include/onnxruntime/core/framework/tensor.h
-- Installing: /usr/local/include/onnxruntime/core/framework/tensor_shape.h
-- Installing: /usr/local/include/onnxruntime/core/providers/cpu
-- Installing: /usr/local/include/onnxruntime/core/providers/cpu/cpu_provider_factory.h
-- Installing: /usr/local/include/onnxruntime/core/optimizer
-- Installing: /usr/local/include/onnxruntime/core/optimizer/graph_transformer.h
-- Installing: /usr/local/include/onnxruntime/core/optimizer/graph_transformer_level.h
-- Installing: /usr/local/include/onnxruntime/core/optimizer/graph_transformer_utils.h
-- Installing: /usr/local/include/onnxruntime/core/optimizer/rewrite_rule.h
-- Installing: /usr/local/include/onnxruntime/core/optimizer/rule_based_graph_transformer.h
-- Installing: /usr/local/include/onnxruntime/core/session
-- Installing: /usr/local/include/onnxruntime/core/session/automl_data_containers.h
-- Installing: /usr/local/include/onnxruntime/core/session/environment.h
-- Installing: /usr/local/include/onnxruntime/core/session/experimental_onnxruntime_cxx_api.h
-- Installing: /usr/local/include/onnxruntime/core/session/experimental_onnxruntime_cxx_inline.h
-- Installing: /usr/local/include/onnxruntime/core/session/onnxruntime_cxx_api.h
-- Installing: /usr/local/include/onnxruntime/core/session/onnxruntime_cxx_inline.h
-- Installing: /usr/local/include/onnxruntime/core/session/onnxruntime_c_api.h
-- Installing: /usr/local/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h
-- Installing: /usr/local/bin/onnx_test_runner

https://github.com/xmba15/onnx_runtime_cpp/blob/master/scripts/install_onnx_runtime.sh

おすすめ

転載: blog.csdn.net/weixin_40437821/article/details/114491673