Skip to content

Commit

Permalink
update the circleci config file by adding workflows both for linux, w…
Browse files Browse the repository at this point in the history
…indows and linux-gpu (open-mmlab#368)

* update circleci by adding more workflows

* fix test workflow failure on windows platform

* fix docker exec command for SDK unittests
  • Loading branch information
lvhan028 committed Jun 29, 2022
1 parent 051e157 commit 30d62e9
Show file tree
Hide file tree
Showing 27 changed files with 526 additions and 55 deletions.
65 changes: 34 additions & 31 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
lint:
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
docker:
- image: cimg/python:3.7.4
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
- checkout
- run:
name: Install pre-commit hook
command: |
pip install pre-commit
pre-commit install
- run:
name: Linting
command: pre-commit run --all-files
- run:
name: Check docstring coverage
command: |
pip install interrogate
interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" --fail-under 80 mmdeploy
# this allows you to use CircleCI's dynamic configuration feature
setup: true

# the path-filtering orb is required to continue a pipeline based on
# the path of an updated fileset
orbs:
path-filtering: circleci/path-filtering@0.1.2

# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
pr_stage_test:
# the always-run workflow is always triggered, regardless of the pipeline parameters.
always-run:
jobs:
- lint
# the path-filtering/filter job determines which pipeline
# parameters to update.
- path-filtering/filter:
name: check-updated-files
# 3-column, whitespace-delimited mapping. One mapping per
# line:
# <regex path-to-test> <parameter-to-set> <value-of-pipeline-parameter>
mapping: |
.circle/.* lint_only false
cmake/.* lint_only false
configs/.* lint_only false
csrc/.* lint_only false
demo/csrc/.* lint_only false
docker/.* lint_only false
mmdeploy/.* lint_only false
requirements/.* lint_only false
tests/.* lint_only false
third_party/.* lint_only false
tools/.* lint_only false
base-revision: master
# this is the path of the configuration we should trigger once
# path filtering and pipeline parameter value updates are
# complete. In this case, we are using the parent dynamic
# configuration itself.
config-path: .circleci/test.yml
41 changes: 41 additions & 0 deletions .circleci/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM nvcr.io/nvidia/tensorrt:21.04-py3

ARG CUDA=11.3
ARG PYTHON_VERSION=3.8
ARG TORCH_VERSION=1.10.0
ARG TORCHVISION_VERSION=0.11.0
ARG MMCV_VERSION=1.5.0
ARG PPLCV_VERSION=0.6.2
ENV FORCE_CUDA="1"

ENV DEBIAN_FRONTEND=noninteractive

### update apt and install libs
RUN apt-get update &&\
apt-get install -y libopencv-dev --no-install-recommends &&\
rm -rf /var/lib/apt/lists/*

RUN curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
chmod +x ~/miniconda.sh && \
~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh && \
/opt/conda/bin/conda install -y python=${PYTHON_VERSION} && \
/opt/conda/bin/conda clean -ya

### pytorch
RUN /opt/conda/bin/conda install pytorch==${TORCH_VERSION} torchvision==${TORCHVISION_VERSION} cudatoolkit=${CUDA} -c pytorch -c conda-forge
ENV PATH /opt/conda/bin:$PATH

### install mmcv-full
RUN /opt/conda/bin/pip install mmcv-full==${MMCV_VERSION} -f https://download.openmmlab.com/mmcv/dist/cu${CUDA//./}/torch${TORCH_VERSION}/index.html

WORKDIR /workspace

### build ppl.cv
RUN git clone https://github.com/openppl-public/ppl.cv.git &&\
cd ppl.cv &&\
git checkout tags/v${PPLCV_VERSION} -b v${PPLCV_VERSION} &&\
./build.sh cuda

# RUN ln -sf /opt/conda /home/circleci/project/conda
ENV TENSORRT_DIR=/workspace/tensorrt
16 changes: 16 additions & 0 deletions .circleci/scripts/linux/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

ARGS=("$@")

cd mmdeploy
MMDEPLOY_DIR=$(pwd)
mkdir -p build && cd build
cmake .. -DMMDEPLOY_BUILD_SDK=ON -DMMDEPLOY_BUILD_TEST=ON -DMMDEPLOY_BUILD_SDK_PYTHON_API=ON \
-DMMDEPLOY_BUILD_SDK_CXX_API=ON -DMMDEPLOY_BUILD_SDK_CSHARP_API=ON \
-DMMDEPLOY_TARGET_DEVICES="$1" -DMMDEPLOY_TARGET_BACKENDS="$2" "${ARGS[@]:2}"

make -j$(nproc) && make install
cd install/example
mkdir -p build
cd build
cmake .. -DMMDeploy_DIR="$MMDEPLOY_DIR"/build/install/lib/cmake/MMDeploy "${ARGS[@]:2}" && make -j$(nproc)
18 changes: 18 additions & 0 deletions .circleci/scripts/linux/convert_onnxruntime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

if [ $# != 2 ]; then
echo "wrong command. usage: bash converter.sh <codebase> <work dir>"
exit 1
fi

if [ "$1" == 'mmcls' ]; then
python3 -m pip install mmcls
git clone --recursive https://github.com/open-mmlab/mmclassification.git
wget https://download.openmmlab.com/mmclassification/v0/resnet/resnet18_8xb32_in1k_20210831-fbbb1da6.pth
python3 mmdeploy/tools/deploy.py \
mmdeploy/configs/mmcls/classification_onnxruntime_dynamic.py \
mmclassification/configs/resnet/resnet18_8xb32_in1k.py \
resnet18_8xb32_in1k_20210831-fbbb1da6.pth \
mmclassification/demo/demo.JPEG \
--work-dir "$2" --dump-info
fi
30 changes: 30 additions & 0 deletions .circleci/scripts/linux/install_onnxruntime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

if [ $# != 2 ]; then
echo "wrong command. usage: bash install_onnxruntime.sh <cpu|cuda> <version>"
exit 1
fi

PLATFORM=$1
VERSION=$2

if [ "$PLATFORM" == 'cpu' ]; then
python -m pip install onnxruntime=="$VERSION"

wget https://github.com/microsoft/onnxruntime/releases/download/v"$VERSION"/onnxruntime-linux-x64-"$VERSION".tgz
tar -zxvf onnxruntime-linux-x64-"$VERSION".tgz
ln -sf onnxruntime-linux-x64-"$VERSION" onnxruntime
elif [ "$PLATFORM" == 'cuda' ]; then
pip install onnxruntime-gpu=="$VERSION"

wget https://github.com/microsoft/onnxruntime/releases/download/v"$VERSION"/onnxruntime-linux-x64-gpu-"$VERSION".tgz
tar -zxvf onnxruntime-linux-x64-gpu-"$VERSION".tgz
ln -sf onnxruntime-linux-x64-gpu-"$VERSION" onnxruntime
else
echo "'$PLATFORM' is not supported"
exit 1
fi

export ONNXRUNTIME_DIR=$(pwd)/onnxruntime
echo "export ONNXRUNTIME_DIR=${ONNXRUNTIME_DIR}" >> ~/.bashrc
echo "export LD_LIBRARY_PATH=$ONNXRUNTIME_DIR/lib:$LD_LIBRARY_PATH" >> ~/.bashrc
17 changes: 17 additions & 0 deletions .circleci/scripts/linux/install_python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

if [ $# -lt 1 ]; then
echo 'use python 3.8.5 as default'
PYTHON_VERSION=3.8.5
else
PYTHON_VERSION=$1
fi

sudo apt-get update
# liblzma-dev need to be installed. Refer to https://github.com/pytorch/vision/issues/2921
# python3-tk tk-dev is for 'import tkinter'
sudo apt-get install -y liblzma-dev python3-tk tk-dev
# python3+ need to be reinstalled due to https://github.com/pytorch/vision/issues/2921
pyenv uninstall -f "$PYTHON_VERSION"
pyenv install "$PYTHON_VERSION"
pyenv global "$PYTHON_VERSION"
19 changes: 19 additions & 0 deletions .circleci/scripts/windows/install_onnxruntime.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
if ($args.Count -lt 2) {
Write-Host "wrong command. usage: intall_onnxruntime.ps1 <cpu|cuda> <version>"
Exit 1
}

$platform = $args[0]
$version = $args[1]

if ($platform -eq "cpu") {
python -m pip install onnxruntime==$version
Invoke-WebRequest -Uri https://github.com/microsoft/onnxruntime/releases/download/v$version/onnxruntime-win-x64-$version.zip -OutFile onnxruntime.zip
Expand-Archive onnxruntime.zip .
Move-Item onnxruntime-win-x64-$version onnxruntime
} elseif ($platform == "cuda") {
Write-Host "TODO: install onnxruntime-gpu"
Exit
} else {
Write-Host "'$platform' is not supported"
}
3 changes: 3 additions & 0 deletions .circleci/scripts/windows/install_opencv.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Invoke-WebRequest -Uri https://download.openmmlab.com/mmdeploy/library/opencv-4.5.5.zip -OutFile opencv.zip
Expand-Archive opencv.zip .
Move-Item opencv-4.5.5 opencv
Loading

0 comments on commit 30d62e9

Please sign in to comment.