summaryrefslogtreecommitdiff
path: root/onnxruntime.spec
blob: b33b1bb741a9122d35613f53509df73fc3716f12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
%global with_npu 0
%define debug_package %{nil}

Name:           onnxruntime
Version:        1.15.1
Release:        1
Summary:        Cross-Platform Accelerated Machine Learning
License:        MIT
URL:            https://onnxruntime.ai/
Source0:        https://github.com/Liiswen/onnxruntime/archive/refs/heads/main.zip
Source1:        abseil-cpp-20230802.0.zip
Source2:        date-3.0.1.zip
Source3:        nsync-1.26.0.zip
Source4:        protobuf-21.12.zip
Source5:        json-3.10.5.zip
Source6:        mp11-boost-1.82.0.zip
Source7:        re2-2022-06-01.zip
Source8:        SafeInt-3.0.28.zip
Source9:        GSL-4.0.0.zip
Source10:       flatbuffers-1.12.0.zip
Source11:       googletest-1.14.0.zip
Source12:       cpuinfo-959002f82d7962a473d8bf301845f2af720e0aa4.zip
Source13:       eigen-3.4.zip
Source14:       onnx-e2525550194ce3d8a2c4a3af451c9d9b3ae6650e.zip
Source15:       pybind11-2.10.1.zip
BuildRoot:      %{_buildrootdir}    
#编译所需包(按照文档写的)
BuildRequires:  cmake gcc gcc-c++ python3 git python-numpy python-packaging openssl openssl-devel iputils bash
#安装所需包(感觉没啥需要的?)
Requires:       bash                               
Provides:       onnxruntime-python-API

%description
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


%description -n onnxruntime-npu
ONNXRuntime npu

%prep
#unzip -q -o ../SOURCES/v%{version}.zip -d ../BUILD

du -sh ../SOURCES/*
mv ../SOURCES/abseil-cpp-20230802.0.zip ../BUILD
mv %{SOURCE2} ../BUILD
mv %{SOURCE3} ../BUILD
mv %{SOURCE4} ../BUILD
mv %{SOURCE5} ../BUILD
mv %{SOURCE6} ../BUILD
mv %{SOURCE7} ../BUILD
mv %{SOURCE8} ../BUILD
mv %{SOURCE9} ../BUILD
mv %{SOURCE10} ../BUILD
mv %{SOURCE11} ../BUILD
mv %{SOURCE12} ../BUILD
mv %{SOURCE13} ../BUILD
mv %{SOURCE14} ../BUILD
mv %{SOURCE15} ../BUILD
unzip -q -o ../SOURCES/main.zip -d ../BUILD



#ping gitee.com
#git clone https://gitee.com/LeaSwen/onnxruntime1.15.1_dep.git

%build

#cd %{name}-%{version}
cd %{name}-main



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
if [ ! -d  %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime ]; then
  mkdir -p  %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}%{python3_sitelib}/onnxruntime
fi

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
%{python3_sitelib}/onnxruntime/datasets
%{python3_sitelib}/onnxruntime/quantization
%{python3_sitelib}/onnxruntime/tools
%{python3_sitelib}/onnxruntime/transformers
%{python3_sitelib}/onnxruntime/__init__.py
%{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
* Fri Aug 10 2023 lisiwen <2022111134@bupt.edu.cn>
- init package