Skip to content

add action for cpp_infer build #4

add action for cpp_infer build

add action for cpp_infer build #4

Workflow file for this run

name: C++ Inference Build
on:
push:
branches: [ "main", ]
paths:
- 'deploy/cpp_infer/**'
- '.github/workflows/cpp_infer.yml'
pull_request:
branches: [ "main", ]
paths:
- 'deploy/cpp_infer/**'
- '.github/workflows/cpp_infer.yml'
workflow_dispatch:
env:
BUILD_TYPE: Release
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
opencv_source_url: https://github.com/opencv/opencv/archive/refs/tags/${{ vars.OPENCV_VERSION }}.tar.gz
paddle_url: https://paddle-inference-lib.bj.bcebos.com/${{ vars.PADDLE_VERSION }}/cxx_c/Linux/CPU/gcc8.2_avx_mkl/paddle_inference.tgz
- os: macos-latest
opencv_source_url: https://github.com/opencv/opencv/archive/refs/tags/${{ vars.OPENCV_VERSION }}.tar.gz
paddle_url: https://paddle-inference-lib.bj.bcebos.com/${{ vars.PADDLE_VERSION }}/cxx_c/MacOS/m1_clang_noavx_accelerate_blas/paddle_inference.tgz
- os: windows-latest
opencv_source_url: https://github.com/opencv/opencv/archive/refs/tags/${{ vars.OPENCV_VERSION }}.tar.gz
paddle_url: https://paddle-inference-lib.bj.bcebos.com/${{ vars.PADDLE_VERSION }}/cxx_c/Windows/CPU/x86-64_avx-mkl-vs2019/paddle_inference.zip
steps:
- uses: actions/checkout@v3
- name: Install Dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake libgoogle-glog-dev libgflags-dev libprotobuf-dev protobuf-compiler
- name: Install Dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install cmake protobuf gflags glog
- name: Setup Visual Studio Environment (Windows)
if: matrix.os == 'windows-latest'
uses: microsoft/setup-msbuild@v1.0.2
- name: Install Dependencies (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install cmake protoc wget unzip
- name: Cache OpenCV
id: cache-opencv
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/opencv-install
key: ${{ runner.os }}-opencv-${{ env.OPENCV_VERSION }}
- name: Build OpenCV
if: steps.cache-opencv.outputs.cache-hit != 'true'
shell: bash
run: |
wget ${{ matrix.opencv_source_url }}
tar -xf opencv-${{ env.OPENCV_VERSION }}.tar.gz
cd opencv-${{ env.OPENCV_VERSION }}
mkdir build && cd build
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cmake -G "Visual Studio 17 2022" -A x64 .. \
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/opencv-install \
-DBUILD_SHARED_LIBS=OFF \
-DWITH_IPP=OFF \
-DBUILD_IPP_IW=OFF \
-DWITH_LAPACK=OFF \
-DWITH_EIGEN=OFF \
-DWITH_ZLIB=ON \
-DBUILD_ZLIB=ON \
-DWITH_JPEG=ON \
-DBUILD_JPEG=ON \
-DWITH_PNG=ON \
-DBUILD_PNG=ON \
-DWITH_TIFF=ON \
-DBUILD_TIFF=ON
else
cmake .. -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/opencv-install \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DWITH_IPP=OFF \
-DBUILD_IPP_IW=OFF \
-DWITH_LAPACK=OFF \
-DWITH_EIGEN=OFF \
-DCMAKE_INSTALL_LIBDIR=lib64 \
-DWITH_ZLIB=ON \
-DBUILD_ZLIB=ON \
-DWITH_JPEG=ON \
-DBUILD_JPEG=ON \
-DWITH_PNG=ON \
-DBUILD_PNG=ON \
-DWITH_TIFF=ON \
-DBUILD_TIFF=ON
fi
cmake --build . --config Release -j4
cmake --install .
- name: Cache Paddle Inference
id: cache-paddle
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/paddle_inference
key: ${{ runner.os }}-paddle-inference-${{ env.PADDLE_VERSION }}
- name: Download Paddle Inference
if: steps.cache-paddle.outputs.cache-hit != 'true'
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
curl -L ${{ matrix.paddle_url }} -o paddle_inference.zip
unzip paddle_inference.zip -d ${{ github.workspace }}/paddle_inference
else
wget ${{ matrix.paddle_url }} -O paddle_inference.tgz
mkdir -p ${{ github.workspace }}/paddle_inference
tar -xf paddle_inference.tgz -C ${{ github.workspace }}/paddle_inference
fi
shell: bash
- name: Configure CMake
shell: bash
run: |
cd deploy/cpp_infer
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cmake -G "Visual Studio 17 2022" -A x64 -B build \
-DPADDLE_LIB="${{ github.workspace }}/paddle_inference" \
-DOPENCV_DIR="${{ github.workspace }}/opencv-install" \
-DWITH_MKL=ON \
-DWITH_GPU=OFF
else
cmake -B build \
-DPADDLE_LIB=${{ github.workspace }}/paddle_inference \
-DOPENCV_DIR=${{ github.workspace }}/opencv-install \
-DWITH_MKL=ON \
-DWITH_GPU=OFF \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
fi
- name: Build
run: |
cd deploy/cpp_infer/build
cmake --build . --config ${{ env.BUILD_TYPE }} -j4
shell: bash