%global pkgvers 1 %global scdate0 20240112 %global schash0 28078b7ad6ad2a43c94b89e49d404d055e5d3796 %global branch0 master %global source0 https://github.com/Tencent/ncnn.git %global sshort0 %{expand:%%{lua:print(('%{schash0}'):sub(1,8))}} # Use it like: git%{sshort0} %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 %global gpu_target_arch "3.5+PTX;5.2;6.1;7.5;8.6" Name: ncnn Version: 20240102 Release: %{scdate0}.%{pkgvers} 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 #setup -T -c -n %{name}-%{version} %autosetup -p1 #git clone --depth 1 -n -b %{branch0} %{source0} . #git fetch --depth 1 origin %{schash0} #git reset --hard %{schash0} ##git submodule update --init #git log --format=fuller %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 ' 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 - 20240112-1 - Init package, import from Balint Cristian