diff options
author | CoprDistGit <infra@openeuler.org> | 2023-08-30 05:59:00 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-08-30 05:59:00 +0000 |
commit | 28f3063a222e6ed7c88b84be5431320682d6b2e8 (patch) | |
tree | 77cae29238a67739bc9b4bea3821045c538e2fa6 | |
parent | 1f0ffac39d96eadd230be1ed6c94fe22f43078d5 (diff) |
automatic import of onnxruntime
-rw-r--r-- | onnxruntime.spec | 98 |
1 files changed, 65 insertions, 33 deletions
diff --git a/onnxruntime.spec b/onnxruntime.spec index 468e487..a94f560 100644 --- a/onnxruntime.spec +++ b/onnxruntime.spec @@ -1,4 +1,6 @@ +%global with_npu 0 %define debug_package %{nil} + Name: onnxruntime Version: 1.15.1 Release: 1 @@ -8,7 +10,7 @@ URL: https://onnxruntime.ai/ Source0: https://github.com/microsoft/onnxruntime/archive/refs/tags/v1.15.1.zip BuildRoot: %{_buildrootdir} #编译所需包(按照文档写的) -BuildRequires: wget cmake gcc gcc-c++ python3 git python-numpy python-packaging +BuildRequires: gcc gcc-c++ python3 git python-numpy python-packaging #安装所需包(感觉没啥需要的?) Requires: bash Provides: onnxruntime-python-API @@ -18,34 +20,30 @@ ONNX Runtime is a cross-platform machine-learning model accelerator, with a flexible interface to integrate hardware-specific libraries. ONNX Runtime can be used with models from PyTorch, Tensorflow/Keras, TFLite, scikit-learn, and other frameworks. +%package -n onnxruntime-npu +Summary: Cross-Platform Accelerated Machine Learning For NPU -%prep -unzip -q -o ../SOURCES/v%{version}.zip -d ../BUILD +%description -n onnxruntime-npu +ONNXRuntime npu +%prep +unzip -q -o ../SOURCES/v%{version}.zip -d ../BUILD %build -#env -wget -O Ascend-cann-toolkit_7.0.RC1.alpha002_linux-x86_64.run https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Ascend%20HDK/Ascend%20HDK%2022.0.0/A300-3010-npu-driver_6.0.0_linux-x86_64.run?response-content-type=application/octet-stream -wget -O Ascend-cann-toolkit_7.0.RC1.alpha002_linux-x86_64.run https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C13SPC702/Ascend-cann-toolkit_7.0.RC1.alpha002_linux-x86_64.run?response-content-type=application/octet-stream -groupadd HwHiAiUser -useradd -g HwHiAiUser -d /home/HwHiAiUser -m HwHiAiUser -s /bin/bash -chmod +x Ascend-cann-toolkit_7.0.RC1.alpha002_linux-x86_64.run -./Ascend-cann-toolkit_7.0.RC1.alpha002_linux-x86_64.run --full --install-for-all -chmod +x Ascend-cann-toolkit_7.0.RC1.alpha002_linux-x86_64.run -./Ascend-cann-toolkit_7.0.RC1.alpha002_linux-x86_64.run --full --install-for-all -source /usr/local/Ascend/ascend-toolkit/set_env.sh - cd %{name}-%{version} -#source /usr/local/Ascend/ascend-toolkit/set_env.sh -#export CPLUS_INCLUDE_PATH=/usr/local/Ascend/ascend-toolkit/latest/fwkacllib/include:$CPLUS_INCLUDE_PATH -#export CPLUS_INCLUDE_PATH=/usr/local/lib64/python3.9/site-packages/numpy/core/include:$CPLUS_INCLUDE_PATH -#ln -s /usr/local/Ascend/ascendtoolkit/latest/x86_64-Linux/1ib64/libascendcl.so /usr/lib/libascendcl.so -#ln -s /usr/local/Ascend/ascendtoolkit/latest/x86_64-Linux/1ib64//libfmk_onnx_parser.so /usr/lib//libfmk_onnx_parser.so -#ln -s /usr/local/Ascend/ascendtoolkit/latest/x86_64-Linux/1ib64/libacl_op_compiler.so /usr/lib/libacl_op_compiler.so - -git init . && bash build.sh --config Release --build_shared_lib --use_cann --parallel --allow_running_as_root --skip_tests --build_wheel --build_dir build/NPU --cann_home /usr/local/Ascend/ascend-toolkit/latest +git init . && bash build.sh --config Release --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --allow_running_as_root --skip_tests --build_wheel --build_dir build/CPU +%if %{with_npu} +export CPLUS_INCLUDE_PATH=/usr/local/Ascend/ascend-toolkit/latest/fwkacllib/include:$CPLUS_INCLUDE_PATH +export CPLUS_INCLUDE_PATH=/usr/local/lib64/python3.9/site-packages/numpy/core/include:$CPLUS_INCLUDE_PATH +ln -s /usr/local/Ascend/ascendtoolkit/latest/x86_64-Linux/1ib64/libascendcl.so /usr/lib/libascendcl.so +ln -s /usr/local/Ascend/ascendtoolkit/latest/x86_64-Linux/1ib64//libfmk_onnx_parser.so /usr/lib//libfmk_onnx_parser.so +ln -s /usr/local/Ascend/ascendtoolkit/latest/x86_64-Linux/1ib64/libacl_op_compiler.so /usr/lib/libacl_op_compiler.so +pip install wheel +source /usr/local/Ascend/ascend-toolkit/set_env.sh +git init . && bash build.sh --config Release --build_shared_lib --use_cann --parallel --allow_running_as_root --skip_tests --build_wheel --build_dir build/NPU +%endif %install @@ -53,18 +51,36 @@ if [ ! -d %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_site mkdir -p %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime fi -cp -r %{_builddir}/%{name}-%{version}/build/Linux/Release/onnxruntime/backend %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ -cp -r %{_builddir}/%{name}-%{version}/build/Linux/Release/onnxruntime/datasets %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ -cp -r %{_builddir}/%{name}-%{version}/build/Linux/Release/onnxruntime/quantization %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ -cp -r %{_builddir}/%{name}-%{version}/build/Linux/Release/onnxruntime/tools %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ -cp -r %{_builddir}/%{name}-%{version}/build/Linux/Release/onnxruntime/transformers %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ -cp -r %{_builddir}/%{name}-%{version}/build/Linux/Release/onnxruntime/__init__.py %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ -cp -r %{_builddir}/%{name}-%{version}/build/Linux/Release/onnxruntime/LICENSE %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ -cp -r %{_builddir}/%{name}-%{version}/build/Linux/Release/onnxruntime/Privacy.md %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ -cp -r %{_builddir}/%{name}-%{version}/build/Linux/Release/onnxruntime/ThirdPartyNotices.txt %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ - +cp -r %{_builddir}/%{name}-%{version}/build/CPU/Release/onnxruntime/backend %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ +cp -r %{_builddir}/%{name}-%{version}/build/CPU/Release/onnxruntime/datasets %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ +cp -r %{_builddir}/%{name}-%{version}/build/CPU/Release/onnxruntime/quantization %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ +cp -r %{_builddir}/%{name}-%{version}/build/CPU/Release/onnxruntime/tools %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ +cp -r %{_builddir}/%{name}-%{version}/build/CPU/Release/onnxruntime/transformers %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ +cp -r %{_builddir}/%{name}-%{version}/build/CPU/Release/onnxruntime/__init__.py %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ +cp -r %{_builddir}/%{name}-%{version}/build/CPU/Release/onnxruntime/LICENSE %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ +cp -r %{_builddir}/%{name}-%{version}/build/CPU/Release/onnxruntime/Privacy.md %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ +cp -r %{_builddir}/%{name}-%{version}/build/CPU/Release/onnxruntime/ThirdPartyNotices.txt %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ +cp -r %{_builddir}/%{name}-%{version}/build/CPU/Release/onnxruntime/capi %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime/ #cp -r %{_builddir}/%{name}-%{version}/build/CPU/Release/onnxruntime/* %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime +%if %{with_npu} + +if [ ! -d %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime_npu ]; then + mkdir -p %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime_npu +fi +cp -r %{_builddir}/%{name}-%{version}/build/NPU/Release/onnxruntime/backend %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime_npu/ +cp -r %{_builddir}/%{name}-%{version}/build/NPU/Release/onnxruntime/datasets %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime_npu/ +cp -r %{_builddir}/%{name}-%{version}/build/NPU/Release/onnxruntime/quantization %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime_npu/ +cp -r %{_builddir}/%{name}-%{version}/build/NPU/Release/onnxruntime/tools %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime_npu/ +cp -r %{_builddir}/%{name}-%{version}/build/NPU/Release/onnxruntime/transformers %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime_npu/ +cp -r %{_builddir}/%{name}-%{version}/build/NPU/Release/onnxruntime/__init__.py %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime_npu/ +cp -r %{_builddir}/%{name}-%{version}/build/NPU/Release/onnxruntime/LICENSE %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime_npu/ +cp -r %{_builddir}/%{name}-%{version}/build/NPU/Release/onnxruntime/Privacy.md %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime_npu/ +cp -r %{_builddir}/%{name}-%{version}/build/NPU/Release/onnxruntime/ThirdPartyNotices.txt %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime_npu/ +cp -r %{_builddir}/%{name}-%{version}/build/NPU/Release/onnxruntime/capi %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime_npu/ +#cp -r %{_builddir}/%{name}-%{version}/build/NPU/Release/onnxruntime/* %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime_npu +%endif + %files %{python3_sitelib}/onnxruntime/backend @@ -76,7 +92,23 @@ cp -r %{_builddir}/%{name}-%{version}/build/Linux/Release/onnxruntime/ThirdParty %{python3_sitelib}/onnxruntime/LICENSE %{python3_sitelib}/onnxruntime/Privacy.md %{python3_sitelib}/onnxruntime/ThirdPartyNotices.txt - +%{python3_sitelib}/onnxruntime/capi +%{python3_sitelib}/onnxruntime/__pycache__ + +%if %{with_npu} +%files -n onnxruntime-npu +%{python3_sitelib}/onnxruntime_npu/backend +%{python3_sitelib}/onnxruntime_npu/datasets +%{python3_sitelib}/onnxruntime_npu/quantization +%{python3_sitelib}/onnxruntime_npu/tools +%{python3_sitelib}/onnxruntime_npu/transformers +%{python3_sitelib}/onnxruntime_npu/__init__.py +%{python3_sitelib}/onnxruntime_npu/LICENSE +%{python3_sitelib}/onnxruntime_npu/Privacy.md +%{python3_sitelib}/onnxruntime_npu/ThirdPartyNotices.txt +%{python3_sitelib}/onnxruntime_npu/capi +%{python3_sitelib}/onnxruntime_npu/__pycache__ +%endif %changelog |