From 675cbe1244c2d1f14e029970e5ed66e86e076c23 Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Tue, 14 Apr 2020 17:38:45 +0200 Subject: [PATCH 1/6] [ONNX runtime] Update for powerpc --- onnxruntime.spec | 11 +++-------- pip/onnx.file | 5 +++-- protobuf.spec | 2 +- py2-onnx.patch | 13 +++++++++++++ 4 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 py2-onnx.patch diff --git a/onnxruntime.spec b/onnxruntime.spec index 825a6fbbf98..60b267d2171 100644 --- a/onnxruntime.spec +++ b/onnxruntime.spec @@ -1,12 +1,12 @@ ### RPM external onnxruntime 1.0.0 ## INITENV +PATH PYTHON3PATH %{i}/${PYTHON3_LIB_SITE_PACKAGES} -%define tag 0f048da7774428d5fb2c4c808fc5820809ab24b8 -%define branch cms/v1.0.0_pb380 +%define tag 9cc0b816f299d326e75f882123d6b2c370328156 +%define branch cms/v1.2.0_plus_ppc_update %define github_user cms-externals Source: git+https://github.com/%{github_user}/%{n}.git?obj=%{branch}/%{tag}&export=%{n}-%{realversion}&submodules=1&output=/%{n}-%{realversion}.tgz BuildRequires: cmake ninja -Requires: protobuf py3-numpy py2-onnx zlib libpng +Requires: protobuf py3-numpy py2-wheel py2-onnx zlib libpng %prep %setup -n %{n}-%{realversion} @@ -19,16 +19,12 @@ cmake ../%{n}-%{realversion}/cmake -GNinja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="%{i}" \ -DCMAKE_INSTALL_LIBDIR=lib \ - -Donnxruntime_BUILD_UNIT_TESTS=ON \ -Donnxruntime_ENABLE_PYTHON=ON \ -Donnxruntime_BUILD_SHARED_LIB=ON \ -Donnxruntime_USE_CUDA=OFF \ - -Donnxruntime_USE_NSYNC=OFF \ -Donnxruntime_BUILD_CSHARP=OFF \ - -Donnxruntime_USE_AUTOML=OFF \ -Donnxruntime_USE_EIGEN_FOR_BLAS=ON \ -Donnxruntime_USE_OPENBLAS=OFF \ - -Donnxruntime_USE_MKLDNN=OFF \ -Donnxruntime_USE_MKLML=OFF \ -Donnxruntime_USE_NGRAPH=OFF \ -Donnxruntime_USE_OPENMP=OFF \ @@ -37,7 +33,6 @@ cmake ../%{n}-%{realversion}/cmake -GNinja \ -Donnxruntime_ENABLE_MICROSOFT_INTERNAL=OFF \ -Donnxruntime_USE_BRAINSLICE=OFF \ -Donnxruntime_USE_NUPHAR=OFF \ - -Donnxruntime_USE_EIGEN_THREADPOOL=OFF \ -Donnxruntime_USE_TENSORRT=OFF \ -Donnxruntime_CROSS_COMPILING=OFF \ -Donnxruntime_USE_FULL_PROTOBUF=ON \ diff --git a/pip/onnx.file b/pip/onnx.file index d947e71ae08..85b138a4433 100644 --- a/pip/onnx.file +++ b/pip/onnx.file @@ -1,4 +1,5 @@ -Requires: cmake py2-numpy protobuf py2-protobuf py2-six py2-typing_extensions -Requires: py3-numpy py2-pytest-runner +Requires: cmake py2-numpy protobuf py2-protobuf py2-six py2-typing_extensions py3-numpy py2-pytest-runner +Patch0: py2-onnx + %define PipPreBuild export ONNX_ML=1 %define RelocatePython %{i}/bin/* diff --git a/protobuf.spec b/protobuf.spec index 3da007182cb..1300d03644b 100644 --- a/protobuf.spec +++ b/protobuf.spec @@ -1,4 +1,4 @@ -### RPM external protobuf 3.8.0 +### RPM external protobuf 3.11.4 ## INITENV SETV PROTOBUF_SOURCE %{source0} ## INITENV SETV PROTOBUF_STRIP_PREFIX %{source_prefix} #============= IMPORTANT NOTE ========================# diff --git a/py2-onnx.patch b/py2-onnx.patch new file mode 100644 index 00000000000..34100c82f8a --- /dev/null +++ b/py2-onnx.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8351a52..613ea76 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -226,7 +226,7 @@ function(RELATIVE_PROTOBUF_GENERATE_CPP NAME SRCS HDRS ROOT_DIR DEPEND) + ${ONNX_DLLEXPORT_STR}${CMAKE_CURRENT_BINARY_DIR}) + if(BUILD_ONNX_PYTHON) + list(APPEND PROTOC_ARGS --python_out +- ${ONNX_DLLEXPORT_STR}${CMAKE_CURRENT_BINARY_DIR}) ++ ${CMAKE_CURRENT_BINARY_DIR}) + if(ONNX_GEN_PB_TYPE_STUBS) + # Haven't figured out how to generate mypy stubs on Windows yet + if(NOT WIN32) From 79cdf9bbc42ecbad1621d4677a511892b1869ad2 Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Wed, 15 Apr 2020 17:42:47 +0200 Subject: [PATCH 2/6] Move protobuf to 3.11.3 and build it with cmake. Also update onnxruntime --- onnxruntime.spec | 12 ++++++------ protobuf.spec | 31 ++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/onnxruntime.spec b/onnxruntime.spec index 60b267d2171..d9985097b5c 100644 --- a/onnxruntime.spec +++ b/onnxruntime.spec @@ -1,12 +1,12 @@ -### RPM external onnxruntime 1.0.0 +### RPM external onnxruntime 1.2.0 ## INITENV +PATH PYTHON3PATH %{i}/${PYTHON3_LIB_SITE_PACKAGES} -%define tag 9cc0b816f299d326e75f882123d6b2c370328156 -%define branch cms/v1.2.0_plus_ppc_update +%define tag 5bb24f105798326769fb3168ce70a2a80d4a4377 +%define branch cms/v1.2.0_plus_ppc_update_pb31130 %define github_user cms-externals Source: git+https://github.com/%{github_user}/%{n}.git?obj=%{branch}/%{tag}&export=%{n}-%{realversion}&submodules=1&output=/%{n}-%{realversion}.tgz BuildRequires: cmake ninja -Requires: protobuf py3-numpy py2-wheel py2-onnx zlib libpng +Requires: protobuf py3-numpy py2-wheel py2-onnx zlib libpng py2-pybind11 %prep %setup -n %{n}-%{realversion} @@ -38,8 +38,8 @@ cmake ../%{n}-%{realversion}/cmake -GNinja \ -Donnxruntime_USE_FULL_PROTOBUF=ON \ -Donnxruntime_DISABLE_CONTRIB_OPS=OFF \ -Donnxruntime_USE_PREINSTALLED_PROTOBUF=ON \ - -Dprotobuf_INSTALL_PATH=${PROTOBUF_ROOT} \ - -DCMAKE_PREFIX_PATH="${ZLIB_ROOT};${LIBPNG_ROOT}" + -Donnxruntime_PREFER_SYSTEM_LIB=ON \ + -DCMAKE_PREFIX_PATH="${ZLIB_ROOT};${LIBPNG_ROOT};${PROTOBUF_ROOT};${PY2_PYBIND11_ROOT}" ninja -v %{makeprocesses} -l $(getconf _NPROCESSORS_ONLN) python3 ../%{n}-%{realversion}/setup.py build diff --git a/protobuf.spec b/protobuf.spec index 1300d03644b..63f3e97ed5b 100644 --- a/protobuf.spec +++ b/protobuf.spec @@ -1,4 +1,4 @@ -### RPM external protobuf 3.11.4 +### RPM external protobuf 3.11.3 ## INITENV SETV PROTOBUF_SOURCE %{source0} ## INITENV SETV PROTOBUF_STRIP_PREFIX %{source_prefix} #============= IMPORTANT NOTE ========================# @@ -17,22 +17,31 @@ Source: %{source0} Requires: zlib -BuildRequires: autotools +BuildRequires: cmake ninja %prep %setup -n %{source_prefix} %build -./autogen.sh +rm -rf ../build +mkdir ../build +cd ../build -./configure --prefix %{i} \ - --disable-static \ - --disable-dependency-tracking \ - CXXFLAGS="-I${ZLIB_ROOT}/include" \ - CFLAGS="-I${ZLIB_ROOT}/include" \ - LDFLAGS="-L${ZLIB_ROOT}/lib" -make %{makeprocesses} +cmake ../%{n}-%{realversion}/cmake \ + -G Ninja \ + -DCMAKE_INSTALL_PREFIX="%{i}" \ + -Dprotobuf_BUILD_TESTS=OFF \ + -Dprotobuf_BUILD_SHARED_LIBS=ON \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_CXX_FLAGS="-I${ZLIB_ROOT}/include" \ + -DCMAKE_C_FLAGS="-I${ZLIB_ROOT}/include" \ + -DCMAKE_SHARED_LINKER_FLAGS="-L${ZLIB_ROOT}/lib" \ + -DCMAKE_PREFIX_PATH="${ZLIB_ROOT}" + +ninja -v %{makeprocesses} -l $(getconf _NPROCESSORS_ONLN) %install -make install + +cd ../build +ninja -v %{makeprocesses} -l $(getconf _NPROCESSORS_ONLN) install rm -rf %{i}/lib/pkgconfig From 8ddfd856ad8efd9cab11d11c0a754b7ef82408b6 Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Thu, 16 Apr 2020 17:08:14 +0200 Subject: [PATCH 3/6] get onnxrt fixes for cms --- onnxruntime.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxruntime.spec b/onnxruntime.spec index d9985097b5c..a785ca8f827 100644 --- a/onnxruntime.spec +++ b/onnxruntime.spec @@ -1,6 +1,6 @@ ### RPM external onnxruntime 1.2.0 ## INITENV +PATH PYTHON3PATH %{i}/${PYTHON3_LIB_SITE_PACKAGES} -%define tag 5bb24f105798326769fb3168ce70a2a80d4a4377 +%define tag 5e781408ee4108e56276b7ef33ca0538e1f9ed6f %define branch cms/v1.2.0_plus_ppc_update_pb31130 %define github_user cms-externals Source: git+https://github.com/%{github_user}/%{n}.git?obj=%{branch}/%{tag}&export=%{n}-%{realversion}&submodules=1&output=/%{n}-%{realversion}.tgz From df7232ecb75d2cad90553927e01c9041bd0536eb Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Thu, 16 Apr 2020 18:42:41 +0200 Subject: [PATCH 4/6] latest changes for onnxruntime fixes --- onnxruntime.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxruntime.spec b/onnxruntime.spec index a785ca8f827..4e167fa34a4 100644 --- a/onnxruntime.spec +++ b/onnxruntime.spec @@ -1,6 +1,6 @@ ### RPM external onnxruntime 1.2.0 ## INITENV +PATH PYTHON3PATH %{i}/${PYTHON3_LIB_SITE_PACKAGES} -%define tag 5e781408ee4108e56276b7ef33ca0538e1f9ed6f +%define tag 8679719d81d0d77762d642d00717b189990b4a88 %define branch cms/v1.2.0_plus_ppc_update_pb31130 %define github_user cms-externals Source: git+https://github.com/%{github_user}/%{n}.git?obj=%{branch}/%{tag}&export=%{n}-%{realversion}&submodules=1&output=/%{n}-%{realversion}.tgz From f17074735b2be321c1dfc4da7b095a015eb008cb Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Sat, 18 Apr 2020 16:22:03 +0200 Subject: [PATCH 5/6] enable onnxrt for ppc --- cmssw-tool-conf.spec | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmssw-tool-conf.spec b/cmssw-tool-conf.spec index b63d30ee1e2..e26016dd228 100644 --- a/cmssw-tool-conf.spec +++ b/cmssw-tool-conf.spec @@ -87,9 +87,7 @@ Requires: valgrind-toolfile Requires: cmsswdata-toolfile Requires: zstd-toolfile Requires: hls-toolfile -%ifnarch ppc64le Requires: onnxruntime-toolfile -%endif Requires: hdf5-toolfile Requires: rivet-toolfile From ae3d56121f9b1ea7f51ad98f2ddfadfd323c3e14 Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Wed, 22 Apr 2020 17:54:44 +0200 Subject: [PATCH 6/6] fix for eigen on powerpc. see https://gitlab.com/libeigen/eigen/issues/1718 --- eigen-altivec-fix.patch | 13 +++++++++++++ eigen.spec | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 eigen-altivec-fix.patch diff --git a/eigen-altivec-fix.patch b/eigen-altivec-fix.patch new file mode 100644 index 00000000000..2d15e9f36cf --- /dev/null +++ b/eigen-altivec-fix.patch @@ -0,0 +1,13 @@ +diff --git a/Eigen/src/Core/arch/AltiVec/PacketMath.h b/Eigen/src/Core/arch/AltiVec/PacketMath.h +index 9464264..eda73ec 100755 +--- a/Eigen/src/Core/arch/AltiVec/PacketMath.h ++++ b/Eigen/src/Core/arch/AltiVec/PacketMath.h +@@ -452,7 +452,7 @@ template<> EIGEN_STRONG_INLINE Packet4f pandnot(const Packet4f& a, con + template<> EIGEN_STRONG_INLINE Packet4i pandnot(const Packet4i& a, const Packet4i& b) { return vec_and(a, vec_nor(b, b)); } + + template<> EIGEN_STRONG_INLINE Packet4f pselect(const Packet4f& mask, const Packet4f& a, const Packet4f& b) { +- return vec_sel(b, a, mask); ++ return vec_sel(b, a, reinterpret_cast(mask)); + } + + template<> EIGEN_STRONG_INLINE Packet4f pround(const Packet4f& a) { return vec_round(a); } diff --git a/eigen.spec b/eigen.spec index 4eeafd9e266..231317c4bfa 100644 --- a/eigen.spec +++ b/eigen.spec @@ -11,9 +11,11 @@ %define source_prefix eigen-git-mirror-%{tag} Source: %{source0} BuildRequires: cmake +Patch0: eigen-altivec-fix %prep %setup -n %{source_prefix} +%patch0 -p1 %build mkdir build