blob: dbf7b7c82d42674ea780bb4ba46f33e8b074f39b (
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
|
%undefine _annotated_build
%global _lto_cflags %{nil}
%global __cmake_in_source_build 1
# We don't have cuda on openEuler
%bcond_without cuda
%global have_cuda 0
%if %{without cuda}
%ifarch x86_64 aarch64
%global have_cuda 1
%endif
%endif
%global vcu_maj 12
%global vcu_min 3
Name: ncnn
Version: 20240102
Release: 1
Summary: Neural network inference computing framework optimized for mobile
License: BSD
Source0: %{version}.tar.gz
URL: https://github.com/Tencent/ncnn
BuildRequires: git doxygen cmake ocl-icd-devel
BuildRequires: python3-setuptools python3-devel
BuildRequires: opencv protobuf-devel pybind11-devel
BuildRequires: glslang-devel gcc-c++
%if %{have_cuda}
BuildRequires: cuda-nvcc-%{vcu_maj}-%{vcu_min}
BuildRequires: cuda-nvtx-%{vcu_maj}-%{vcu_min}
BuildRequires: cuda-cudart-devel-%{vcu_maj}-%{vcu_min}
BuildRequires: cuda-nvml-devel-%{vcu_maj}-%{vcu_min}
BuildRequires: cuda-nvrtc-devel-%{vcu_maj}-%{vcu_min}
BuildRequires: cuda-driver-devel-%{vcu_maj}-%{vcu_min}
BuildRequires: cuda-profiler-api-%{vcu_maj}-%{vcu_min}
BuildRequires: libnccl-devel
%endif
%description
High-performance neural network inference computing
framework optimized for mobile platforms.
%package devel
Summary: Development files for %{name}
Requires: %{name} = %{version}-%{release}
%description devel
This package contains development files for %{name}.
%package python3
Summary: Python files for %{name}
Requires: %{name} = %{version}-%{release}
Requires: python3-numpy python3-tqdm python3-requests python3-portalocker opencv-python3
%description python3
This package contains python files for %{name}.
%prep
%autosetup -p1
%build
rm -rf glslang
sed -i 's|ncnn STATIC|ncnn SHARED|' src/CMakeLists.txt
sed -i '/PRIVATE -fvisibility=hidden/d' src/CMakeLists.txt
sed -i 's|DESTINATION lib|DESTINATION %{_lib}|g' src/CMakeLists.txt
sed -i 's|ncnn PROPERTIES|ncnn PROPERTIES SOVERSION 1 VERSION 1.0|' src/CMakeLists.txt
sed -i 's|add_subdirectory(pybind11)|find_package(pybind11 REQUIRED)|' python/CMakeLists.txt
sed -i '1i #include <cstdint>' tools/darknet/darknet2ncnn.cpp
mkdir build
pushd build
%global optflags %(echo %{optflags} | sed 's|-fno-exceptions||')
%cmake .. -Wno-dev \
-DCMAKE_SKIP_RPATH=ON
\
-DCMAKE_VERBOSE_MAKEFILE=OFF \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_LIBDIR=%{_lib} \
-DCMAKE_CXX_FLAGS="%{optflags} -fpermissive" \
%if %{have_cuda}
-DCUDA_TOOLKIT_ROOT_DIR="/usr/local/cuda-%{vcu_maj}.%{vcu_min}/" \
%endif
-DNCNN_SYSTEM_GLSLANG=ON \
%ifnarch x86_64 aarch64
-DNCNN_AVXVNNI=OFF \
-DNCNN_AVX512FP16=OFF \
-DNCNN_AVX512BF16=OFF \
%endif
-DNCNN_SHARED_LIB=ON \
%if "%{_lto_cflags}" == "%{nil}"
-DNCNN_ENABLE_LTO=OFF \
%else
-DNCNN_ENABLE_LTO=ON \
%endif
-DNCNN_DISABLE_EXCEPTION=OFF \
-DNCNN_PYTHON=ON
make %{?_smp_mflags}
popd
%install
rm -rf %{buildroot}
pushd build
make install DESTDIR=%{buildroot}
popd
pushd python
%{__python3} setup.py install --root %{buildroot}
popd
rm -rf %{buildroot}/%{python3_sitelib}/*.egg-info
%files
%doc README.md CONTRIBUTING.md
%{_bindir}/*
%license LICENSE.txt
%{_libdir}/lib*.so*
%files devel
%{_includedir}/*
%{_libdir}/cmake/*
%{_libdir}/pkgconfig/*
%files python3
%{python3_sitelib}/*
%changelog
* Wed Jan 24 2024 misaka00251 <liuxin@iscas.ac.cn> - 20240112-1
- Init package, import from Balint Cristian
|