summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-Hsuan Yen2021-06-03 17:37:31 +0800
committerChih-Hsuan Yen2021-06-03 17:37:51 +0800
commit8ddd1e0bf5f9b951be1fcf2ec0b72465bd0098bc (patch)
treebc75453a12b17b4f368f1832542f22d250be2498
parent75690f7c7fad657006726e3c9f9111c05d5a1ebb (diff)
downloadaur-8ddd1e0bf5f9b951be1fcf2ec0b72465bd0098bc.tar.gz
Enable CUDA and update patches for 1.8.0
Also enables orttraining and use shared libs
-rw-r--r--.SRCINFO45
-rw-r--r--PKGBUILD101
-rw-r--r--build-fixes.patch39
-rw-r--r--clang.patch40
4 files changed, 176 insertions, 49 deletions
diff --git a/.SRCINFO b/.SRCINFO
index e4c6129d429..1f1bc150664 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,10 +1,20 @@
pkgbase = python-onnxruntime
pkgdesc = Cross-platform, high performance scoring engine for ML models
- pkgver = 1.7.2
+ pkgver = 1.8.0
pkgrel = 1
url = https://github.com/microsoft/onnxruntime
arch = x86_64
license = MIT
+ checkdepends = python-pytest
+ checkdepends = python-pytorch
+ checkdepends = python-h5py
+ checkdepends = python-pandas
+ checkdepends = python-psutil
+ checkdepends = python-tqdm
+ checkdepends = python-sympy
+ checkdepends = python-torchvision
+ checkdepends = tensorboard
+ checkdepends = python-cerberus
makedepends = git
makedepends = cmake
makedepends = gtest
@@ -14,24 +24,51 @@ pkgbase = python-onnxruntime
makedepends = nlohmann-json
makedepends = chrono-date
makedepends = boost
+ makedepends = flatbuffers
+ makedepends = cuda
+ makedepends = cudnn
+ makedepends = nccl
+ makedepends = clang
depends = nsync
depends = re2
- depends = flatbuffers
+ depends = python-flatbuffers
depends = python-numpy
depends = python-onnx
depends = python-protobuf
- source = git+https://github.com/microsoft/onnxruntime#tag=v1.7.2
+ depends = openmpi
+ source = git+https://github.com/microsoft/onnxruntime#tag=v1.8.0
source = git+https://gitlab.com/libeigen/eigen.git
source = git+https://github.com/onnx/onnx.git
source = git+https://github.com/dcleblanc/SafeInt.git
source = git+https://github.com/martinmoene/optional-lite.git
+ source = git+https://github.com/tensorflow/tensorboard.git
+ source = git+https://github.com/dmlc/dlpack.git
+ source = git+https://github.com/jarro2783/cxxopts.git
source = build-fixes.patch
+ source = clang.patch
sha512sums = SKIP
sha512sums = SKIP
sha512sums = SKIP
sha512sums = SKIP
sha512sums = SKIP
- sha512sums = 90e67eb144770734b488bf8ac5ad0dc955d2d860d9ed1c32285ffe913e72d27a3ac5b27588f41042fa4008533234e6cf4740c600f2b3fdce90ef8a3f853827eb
+ sha512sums = SKIP
+ sha512sums = SKIP
+ sha512sums = SKIP
+ sha512sums = 685f0235abed6e1277dd0eb9bda56c464d1987fe7fc90a3550e17ec70cc49fd15f34996a0e159f9622c4ca3e6bf29917fe51b7849342531fa2a6808d782f1e06
+ sha512sums = 55ba879c015df11582ff4afaa9ccca19c0e3d3a8be503629718402dbdc826e36bc3ec3ce4dd589705371d7fcf250ba2a9b30c5a3dd0cfccb8e008346f1bd6252
pkgname = python-onnxruntime
+pkgname = python-onnxruntime-cuda
+ depends = nsync
+ depends = re2
+ depends = python-flatbuffers
+ depends = python-numpy
+ depends = python-onnx
+ depends = python-protobuf
+ depends = openmpi
+ depends = cuda
+ depends = cudnn
+ depends = nccl
+ provides = python-onnxruntime=1.8.0
+ conflicts = python-onnxruntime
diff --git a/PKGBUILD b/PKGBUILD
index 691a8b92565..78f18b09f80 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,14 +1,16 @@
# Maintainer: Chih-Hsuan Yen <yan12125@gmail.com>
-pkgname=python-onnxruntime
-pkgver=1.7.2
+pkgbase=python-onnxruntime
+pkgname=(python-onnxruntime python-onnxruntime-cuda)
+pkgver=1.8.0
pkgdesc='Cross-platform, high performance scoring engine for ML models'
pkgrel=1
arch=(x86_64)
url='https://github.com/microsoft/onnxruntime'
license=(MIT)
-depends=(nsync re2 flatbuffers python-numpy python-onnx python-protobuf)
-makedepends=(git cmake gtest gmock pybind11 python-setuptools nlohmann-json chrono-date boost)
+depends=(nsync re2 python-flatbuffers python-numpy python-onnx python-protobuf openmpi)
+makedepends=(git cmake gtest gmock pybind11 python-setuptools nlohmann-json chrono-date boost flatbuffers cuda cudnn nccl clang)
+checkdepends=(python-pytest python-pytorch python-h5py python-pandas python-psutil python-tqdm python-sympy python-torchvision tensorboard python-cerberus)
# not de-vendored libraries
# eigen: API changes a lot since extra/eigen 3.3.7 to the commit onnxruntime uses
# onnx: needs shared libonnx (https://github.com/onnx/onnx/issues/3030)
@@ -18,53 +20,118 @@ source=("git+https://github.com/microsoft/onnxruntime#tag=v$pkgver"
"git+https://github.com/onnx/onnx.git"
"git+https://github.com/dcleblanc/SafeInt.git"
"git+https://github.com/martinmoene/optional-lite.git"
- build-fixes.patch)
+ "git+https://github.com/tensorflow/tensorboard.git"
+ "git+https://github.com/dmlc/dlpack.git"
+ "git+https://github.com/jarro2783/cxxopts.git"
+ build-fixes.patch
+ clang.patch)
sha512sums=('SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
- '90e67eb144770734b488bf8ac5ad0dc955d2d860d9ed1c32285ffe913e72d27a3ac5b27588f41042fa4008533234e6cf4740c600f2b3fdce90ef8a3f853827eb')
+ 'SKIP'
+ 'SKIP'
+ 'SKIP'
+ '685f0235abed6e1277dd0eb9bda56c464d1987fe7fc90a3550e17ec70cc49fd15f34996a0e159f9622c4ca3e6bf29917fe51b7849342531fa2a6808d782f1e06'
+ '55ba879c015df11582ff4afaa9ccca19c0e3d3a8be503629718402dbdc826e36bc3ec3ce4dd589705371d7fcf250ba2a9b30c5a3dd0cfccb8e008346f1bd6252')
prepare() {
cd onnxruntime
patch -Np1 -i ../build-fixes.patch
+ patch -Np1 -i ../clang.patch
git submodule init
- for mod in eigen onnx SafeInt optional-lite; do
+ for mod in eigen onnx SafeInt optional-lite tensorboard dlpack cxxopts; do
git config submodule.cmake/external/$mod.url "$srcdir"/$mod
git submodule update cmake/external/$mod
done
}
-build() {
+_build() {
+ build_dir=$1
+ shift
+
cd "$srcdir"/onnxruntime
# Use protobuf-lite instead of full protobuf to workaround symbol conflicts
# with onnx; see https://github.com/onnx/onnx/issues/1277 for details.
- cmake -B build -S cmake \
+ CC=/usr/bin/clang CXX=/usr/bin/clang++ \
+ cmake -B $build_dir -S cmake \
+ -DCMAKE_INSTALL_PREFIX=/usr \
-Donnxruntime_ENABLE_PYTHON=ON \
-DONNX_CUSTOM_PROTOC_EXECUTABLE=/usr/bin/protoc \
-Donnxruntime_PREFER_SYSTEM_LIB=ON \
- -Donnxruntime_USE_FULL_PROTOBUF=OFF
+ -Donnxruntime_USE_FULL_PROTOBUF=OFF \
+ -Donnxruntime_BUILD_SHARED_LIB=ON \
+ -Donnxruntime_ENABLE_TRAINING=ON \
+ -Donnxruntime_USE_MPI=ON \
+ "$@"
- cd build
+ cd $build_dir
make
python ../setup.py build
}
-check() {
- cd onnxruntime/build
+build() {
+ _build build
+
+ # Use clang as GCC does not work. GCC 11 uses C++ 17 by default. On the
+ # other hand, onnxruntime uses C++ 14. However, nvcc does not correctly
+ # pass -std=c++14 to the host compiler, and thus preprocessed files
+ # contains C++ 17 language features, and cicc failed to parse it. GCC 10
+ # does not work, either, as some dependent packages (ex: re2) are built
+ # with libstdc++ 11, and linking onnxruntime with libstdc++ 10 fails.
+ _build build-cuda \
+ -DCMAKE_CUDA_HOST_COMPILER=/usr/bin/clang \
+ -Donnxruntime_USE_CUDA=ON \
+ -Donnxruntime_CUDA_HOME=/opt/cuda \
+ -Donnxruntime_CUDNN_HOME=/usr \
+ -Donnxruntime_USE_NCCL=ON
+}
+
+_check() {
make test
+ # launch_test.py seems a script, and orttraining_* include BERT tests, which require the
+ # transformers package, and failed even if the latter is installed.
+ LD_LIBRARY_PATH="$PWD" pytest \
+ --ignore launch_test.py \
+ --ignore orttraining_run_bert_pretrain.py \
+ --ignore orttraining_run_frontend_batch_size_test.py
}
-package() {
- cd onnxruntime/build
+check() {
+ cd "$srcdir"/onnxruntime/build
+ _check
+
+ cd "$srcdir"/onnxruntime/build-cuda
+ # _check # requires machines with CUDA-compatible devices
+}
+
+_package() {
+ make install DESTDIR="$pkgdir"
+
python ../setup.py install --root="$pkgdir" --skip-build --optimize=1
- PY_SITE_DIR="$(python -c 'import site; print(site.getsitepackages()[0])')"
+ PY_ORT_DIR="$(python -c 'import site; print(site.getsitepackages()[0])')/onnxruntime"
install -Ddm755 "$pkgdir"/usr/share/licenses/$pkgname
for f in LICENSE ThirdPartyNotices.txt ; do
- ln -s "$PY_SITE_DIR/onnxruntime/$f" "$pkgdir"/usr/share/licenses/$pkgname/$f
+ ln -s "$PY_ORT_DIR/$f" "$pkgdir"/usr/share/licenses/$pkgname/$f
done
+ # already installed by `make install`, and not useful as this path is not looked up by the linker
+ rm -vf "$pkgdir/$PY_ORT_DIR"/capi/libonnxruntime_providers_*
+}
+
+package_python-onnxruntime() {
+ cd onnxruntime/build
+ _package
+}
+
+package_python-onnxruntime-cuda() {
+ depends+=(cuda cudnn nccl)
+ conflicts=(python-onnxruntime)
+ provides=("python-onnxruntime=$pkgver")
+
+ cd onnxruntime/build-cuda
+ _package
}
diff --git a/build-fixes.patch b/build-fixes.patch
index 5c452420288..129aa988523 100644
--- a/build-fixes.patch
+++ b/build-fixes.patch
@@ -1,17 +1,8 @@
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
-index a07893771c..253843fa5b 100644
+index a027c69e0..eb7608518 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
-@@ -596,7 +596,7 @@ if(Protobuf_FOUND OR Protobuf_FOUND)
- if(NOT Protobuf_USE_STATIC_LIBS)
- #Indeed here should be a warning, not a fatal error. ONNX Runtime itself can work in such a
- #setting but it may cause compatibility issue when ONNX Runtime is integrated with the other ONNX ecosystem softwares.
-- message(FATAL_ERROR "Please enable Protobuf_USE_STATIC_LIBS")
-+ message(WARNING "Please enable Protobuf_USE_STATIC_LIBS")
- endif()
- else()
- set(PROTOBUF_LIB protobuf::libprotobuf-lite)
-@@ -657,7 +657,8 @@ get_filename_component(ORTTRAINING_ROOT "${ORTTRAINING_ROOT}" ABSOLUTE)
+@@ -753,7 +753,8 @@ get_filename_component(ORTTRAINING_ROOT "${ORTTRAINING_ROOT}" ABSOLUTE)
get_filename_component(REPO_ROOT "${REPO_ROOT}" ABSOLUTE)
set(ONNXRUNTIME_INCLUDE_DIR ${REPO_ROOT}/include/onnxruntime)
@@ -21,7 +12,7 @@ index a07893771c..253843fa5b 100644
set(SAFEINT_INCLUDE_DIR ${REPO_ROOT}/cmake/external/SafeInt)
add_library(safeint_interface INTERFACE)
-@@ -668,10 +669,13 @@ if(onnxruntime_DISABLE_EXCEPTIONS)
+@@ -764,14 +765,17 @@ if(onnxruntime_DISABLE_EXCEPTIONS)
add_compile_definitions(optional_CONFIG_NO_EXCEPTIONS=1)
endif()
@@ -29,6 +20,11 @@ index a07893771c..253843fa5b 100644
+add_library(boost_mp11 INTERFACE)
+add_library(Boost::mp11 ALIAS boost_mp11)
+ set(JSON_BuildTests OFF CACHE INTERNAL "")
+ set(JSON_Install OFF CACHE INTERNAL "")
+-add_subdirectory(external/json EXCLUDE_FROM_ALL)
++find_package(nlohmann_json REQUIRED)
+
if(onnxruntime_PREFER_SYSTEM_LIB)
- find_package(re2)
+ find_package(PkgConfig)
@@ -37,26 +33,13 @@ index a07893771c..253843fa5b 100644
endif()
if(NOT TARGET re2::re2)
add_subdirectory(external/re2 EXCLUDE_FROM_ALL)
-@@ -947,7 +951,8 @@ set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "FLATBUFFERS_BUILD_TESTS" FORCE)
- set(FLATBUFFERS_INSTALL OFF CACHE BOOL "FLATBUFFERS_INSTALL" FORCE)
+@@ -1261,7 +1265,8 @@ set(FLATBUFFERS_INSTALL OFF CACHE BOOL "FLATBUFFERS_INSTALL" FORCE)
set(FLATBUFFERS_BUILD_FLATHASH OFF CACHE BOOL "FLATBUFFERS_BUILD_FLATHASH" FORCE)
set(FLATBUFFERS_BUILD_FLATLIB ON CACHE BOOL "FLATBUFFERS_BUILD_FLATLIB" FORCE)
+ set_msvc_c_cpp_compiler_warning_level(4)
-add_subdirectory(external/flatbuffers EXCLUDE_FROM_ALL)
+find_package(Flatbuffers REQUIRED)
+add_library(flatbuffers ALIAS flatbuffers::flatbuffers_shared)
+ set_msvc_c_cpp_compiler_warning_level(3)
list(APPEND onnxruntime_EXTERNAL_DEPENDENCIES flatbuffers)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES flatbuffers)
-
-diff --git a/onnxruntime/core/session/inference_session_utils.h b/onnxruntime/core/session/inference_session_utils.h
-index 5899afac8d..2672be649d 100644
---- a/onnxruntime/core/session/inference_session_utils.h
-+++ b/onnxruntime/core/session/inference_session_utils.h
-@@ -18,7 +18,7 @@
- #pragma warning(push)
- #pragma warning(disable : 28020)
- #endif
--#include "single_include/nlohmann/json.hpp"
-+#include <nlohmann/json.hpp>
- #ifdef _WIN32
- #pragma warning(pop)
- #endif
diff --git a/clang.patch b/clang.patch
new file mode 100644
index 00000000000..e1445eb36df
--- /dev/null
+++ b/clang.patch
@@ -0,0 +1,40 @@
+diff --git a/onnxruntime/core/providers/cuda/reduction/reduction_functions.cc b/onnxruntime/core/providers/cuda/reduction/reduction_functions.cc
+index 955df6d9a..f9fd53e15 100644
+--- a/onnxruntime/core/providers/cuda/reduction/reduction_functions.cc
++++ b/onnxruntime/core/providers/cuda/reduction/reduction_functions.cc
+@@ -17,7 +17,7 @@ namespace cuda {
+
+ namespace {
+ // std::make_reverse_iterator is not implemented in older versions of GCC
+-#if !defined(__GNUC__) || __GNUC__ >= 5
++#if !defined(__GNUC__) || __GNUC__ >= 5 || defined(__clang__)
+ using std::make_reverse_iterator;
+ #else
+ template <typename It>
+@@ -39,7 +39,7 @@ optional<std::pair<int64_t, int64_t>> GetMinAndMaxContiguousAxes(
+ }
+
+ // normalize axis values and sort
+- const std::vector<int64_t> axes = [&original_axes, rank]() {
++ const std::vector<int64_t> axes = [&original_axes, rank]() -> std::vector<int64_t> {
+ std::vector<int64_t> result(original_axes);
+ std::for_each(
+ result.begin(), result.end(),
+@@ -73,7 +73,7 @@ optional<std::pair<int64_t, int64_t>> GetMinAndMaxContiguousAxes(
+ }
+
+ // expand axes over surrounding dimensions with value of 1
+- const int64_t min_axis = [&dims, &axes, &is_dim_one]() {
++ const int64_t min_axis = [&dims, &axes, &is_dim_one]() -> int64_t {
+ const auto& min_given_axis = axes.front();
+ // note that std::reverse_iterator(it) refers to the element at (it-1)
+ // it -> reverse it: element offset of -1
+@@ -85,7 +85,7 @@ optional<std::pair<int64_t, int64_t>> GetMinAndMaxContiguousAxes(
+ return std::distance(dims.begin(), before_min_axis_rit.base());
+ }();
+
+- const int64_t max_axis = [&dims, &axes, &is_dim_one]() {
++ const int64_t max_axis = [&dims, &axes, &is_dim_one]() -> int64_t {
+ const auto& max_given_axis = axes.back();
+ const auto after_max_given_axis_it = dims.begin() + max_given_axis + 1;
+ const auto after_max_axis_it =