Add a dockerfile and update for build script. (#131)
* Add a dockerfile and update for build script. * update
This commit is contained in:
Родитель
1ae69c0f7a
Коммит
ef4e07c5f4
|
@ -32,7 +32,7 @@ option(OCOS_ENABLE_BERT_TOKENIZER "Enable the BertTokenizer building" ON)
|
|||
option(OCOS_ENABLE_BLINGFIRE "Enable the Blingfire building" ON)
|
||||
option(OCOS_ENABLE_MATH "Enable the math tensor operators building" ON)
|
||||
option(OCOS_ENABLE_STATIC_LIB "Enable generating static library" OFF)
|
||||
option(OCOS_ENABLE_OPLIST_FILE "Enable including the selected_ops tool file" OFF)
|
||||
option(OCOS_ENABLE_SELECTED_OPLIST "Enable including the selected_ops tool file" OFF)
|
||||
|
||||
|
||||
function(disable_all_operators)
|
||||
|
@ -72,7 +72,7 @@ endif()
|
|||
# External dependencies
|
||||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/externals ${PROJECT_SOURCE_DIR}/cmake)
|
||||
|
||||
if (OCOS_ENABLE_OPLIST_FILE)
|
||||
if (OCOS_ENABLE_SELECTED_OPLIST)
|
||||
message(STATUS "Looking for the _selectedoplist.cmake")
|
||||
disable_all_operators()
|
||||
include(_selectedoplist)
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The example file on building the static library for android
|
||||
set -e -x -u
|
||||
|
||||
OSNAME=android
|
||||
if [ -z "$NDK_ROOT" ]; then export NDK_ROOT=`ls -d $HOME/Android/ndk/* 2>/dev/null`; fi
|
||||
if [ -z "$NDK_ROOT" ]
|
||||
then
|
||||
echo "ERROR: cannot find where NDK was installed, using NDK_ROOT to specify it"
|
||||
exit 7
|
||||
fi
|
||||
|
||||
mkdir -p out/$OSNAME/Release && cd out/$OSNAME/Release
|
||||
|
||||
cmake "$@" \
|
||||
-DCMAKE_TOOLCHAIN_FILE=${NDK_ROOT}/build/cmake/android.toolchain.cmake \
|
||||
-DANDROID_NDK=${NDK_ROOT} \
|
||||
-DANDROID_ABI=armeabi-v7a \
|
||||
-DANDROID_PLATFORM=android-19 \
|
||||
-DOCOS_ENABLE_STATIC_LIB=ON \
|
||||
../../.. && cmake --build . --config Release --parallel
|
17
build.sh
17
build.sh
|
@ -1,8 +1,11 @@
|
|||
OSNAME=$(uname -s)
|
||||
mkdir -p out/$OSNAME
|
||||
cd out/$OSNAME || exit 103
|
||||
#!/bin/bash
|
||||
|
||||
cmake "$@" ../.. && cmake --build . --config RelWithDebInfo --parallel
|
||||
build_error=$?
|
||||
cd ../..
|
||||
exit $build_error
|
||||
# The example build script to build the source in Linux-like platform
|
||||
set -e -x -u
|
||||
|
||||
OSNAME=$(uname -s)
|
||||
BUILD_FLAVOR=RelWithDebInfo
|
||||
target_dir=out/$OSNAME/$BUILD_FLAVOR
|
||||
mkdir -p $target_dir && cd $target_dir
|
||||
|
||||
cmake "$@" ../../.. && cmake --build . --config $BUILD_FLAVOR --parallel
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# Dockerfile
|
||||
|
||||
This folder contains the docker file to help the user to build the packages from the source.
|
||||
|
||||
## onnx_ort_ext
|
||||
Build ONNX, ONNXRuntime and ONNXRuntime-Extensions packages from the onnxruntime current master branch,
|
||||
or from the source folder onnx_ort_ext/onnxruntime if it exists.
|
|
@ -0,0 +1,71 @@
|
|||
# This Dockerfile will build Docker Image with
|
||||
# ONNX (from ONNXRuntime submodule) + ONNXRuntime + ONNXRuntime-Extensions
|
||||
# installed for CPU only
|
||||
#
|
||||
# Example commandline to build this full package set.
|
||||
# docker build . -t docker-image-repo-name
|
||||
# Example commandline to run the built docker container:
|
||||
# sudo docker run --name container-name -it docker-image-repo-name
|
||||
|
||||
ARG PYTHON_VERSION=3.8
|
||||
|
||||
FROM ubuntu:18.04
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
apt-utils \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
ccache \
|
||||
cmake \
|
||||
curl \
|
||||
git \
|
||||
wget \
|
||||
gcc-8 \
|
||||
g++-8 \
|
||||
libprotobuf-dev \
|
||||
protobuf-compiler && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 100 && \
|
||||
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 100
|
||||
RUN /usr/sbin/update-ccache-symlinks
|
||||
RUN mkdir /opt/ccache && ccache --set-config=cache_dir=/opt/ccache
|
||||
|
||||
ENV PATH /opt/conda/bin:$PATH
|
||||
|
||||
RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
|
||||
chmod +x ~/miniconda.sh && \
|
||||
~/miniconda.sh -b -p /opt/conda && \
|
||||
rm ~/miniconda.sh && \
|
||||
/opt/conda/bin/conda install -y python=${PYTHON_VERSION} conda-build && \
|
||||
/opt/conda/bin/conda install -y numpy ninja setuptools cmake protobuf typing-extensions && \
|
||||
/opt/conda/bin/conda clean -ya
|
||||
|
||||
ADD . /source
|
||||
WORKDIR /root
|
||||
RUN if [ -d /source/onnnxruntime ] ; then ln -s /source/onnxruntime /root/onnxruntime ; fi
|
||||
RUN if [ ! -L /root/onnxruntime ] ; then git clone https://github.com/microsoft/onnxruntime.git && \
|
||||
cd onnxruntime && git submodule update --init --recursive ; fi
|
||||
|
||||
RUN cd /root/onnxruntime/cmake/external/onnx && \
|
||||
CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=ON" python3 setup.py bdist_wheel && \
|
||||
python3 -m pip install dist/*.whl
|
||||
|
||||
RUN cd /root/onnxruntime && \
|
||||
/bin/bash ./build.sh \
|
||||
--config Release \
|
||||
--build_wheel \
|
||||
--update \
|
||||
--build \
|
||||
--parallel \
|
||||
--skip_submodule_sync \
|
||||
--cmake_extra_defines \
|
||||
ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) && \
|
||||
python3 -m pip install /root/onnxruntime/build/Linux/Release/dist/*.whl
|
||||
|
||||
RUN cd /root/onnxruntime/cmake/external/onnxruntime-extensions && \
|
||||
python3 setup.py bdist_wheel && \
|
||||
python3 -m pip install dist/*.whl
|
||||
|
||||
RUN if [ -L /root/onnxruntime ]; then unlink /root/onnxruntime ; fi && \
|
||||
if [ -d /root/onnxruntime ]; then rm -rf /root/onnxruntime ; fi && \
|
||||
rm -rf /opt/ccache
|
Загрузка…
Ссылка в новой задаче