Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement(installation): add script install mmdeploy #919

Merged
merged 35 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
291d37e
feat(tools): add build ubuntu x64 ncnn
tpoisonooo Aug 16, 2022
b1b8a5b
ci(tools): add ncnn auto install
tpoisonooo Aug 17, 2022
7a37f05
fix(ci): auto install ncnn
tpoisonooo Aug 17, 2022
361754f
fix(tools): no interactive
tpoisonooo Aug 18, 2022
954bb7c
docs(build): add script build
tpoisonooo Aug 18, 2022
60e82c9
CI(ncnn): script install ncnn
tpoisonooo Aug 18, 2022
299a770
docs(zh_cn): fix error os
tpoisonooo Aug 18, 2022
3e7227d
fix
tpoisonooo Aug 19, 2022
1812ac2
CI(tools/script): test ort install passed
tpoisonooo Aug 19, 2022
831b666
update
tpoisonooo Aug 19, 2022
9e89259
CI(tools): support pplnn
tpoisonooo Aug 19, 2022
961f95d
CI(build): add pplnn
tpoisonooo Aug 19, 2022
7d7f058
docs(tools): update
tpoisonooo Aug 19, 2022
15811f8
fix
tpoisonooo Aug 19, 2022
b172dc3
CI(tools): script install torchscript
tpoisonooo Aug 22, 2022
afd2a49
docs(build): add torchscript
tpoisonooo Aug 22, 2022
d3575e7
fix(tools): clean code and doc
tpoisonooo Aug 22, 2022
972cba8
update
tpoisonooo Aug 22, 2022
27bd702
fix(CI): requirements install failed
tpoisonooo Aug 22, 2022
a22add7
debug CI
tpoisonooo Aug 22, 2022
792d744
update
tpoisonooo Aug 22, 2022
e370df4
update
tpoisonooo Aug 22, 2022
a277921
update
tpoisonooo Aug 22, 2022
19c8054
feat(tools/script): support user specify make jobs
tpoisonooo Aug 23, 2022
6c1902d
fix(tools/script): fix build pplnn with cuda
tpoisonooo Aug 23, 2022
e2e2509
fix(tools/script): torchscript add tips and simplify install mmcv
tpoisonooo Aug 23, 2022
8f0fd3f
fix(tools/script): check nvcc version first
tpoisonooo Aug 23, 2022
7f19a6c
fix(tools/scripts): pplnn checkout
tpoisonooo Aug 25, 2022
977ef39
fix(CI): add simple check install succcess
tpoisonooo Aug 25, 2022
a721e42
fix
tpoisonooo Aug 25, 2022
150858f
debug CI
tpoisonooo Aug 25, 2022
a64190d
fix
tpoisonooo Aug 25, 2022
ce16fc5
fix(CI): pplnn install mis wheel
tpoisonooo Aug 25, 2022
aa449c9
fix(CI): build error
tpoisonooo Aug 25, 2022
5721ab3
fix(CI): remove misleading message
tpoisonooo Aug 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/backend-ncnn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,25 @@ jobs:
echo $(pwd)
ln -s build/bin/mmdeploy_onnx2ncnn ./
python3 .github/scripts/test_onnx2ncnn.py --run 1
script_install:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.7]
torch: [1.9.0]
include:
- torch: 1.9.0
torch_version: torch1.9
torchvision: 0.10.0
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install mmdeploy
run: |
python3 tools/scripts/build_ubuntu_x64_ncnn.py
tpoisonooo marked this conversation as resolved.
Show resolved Hide resolved
41 changes: 41 additions & 0 deletions .github/workflows/backend-ort.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: backend-ort

on:
push:
paths-ignore:
- "demo/**"
- "tools/**"

pull_request:
paths-ignore:
- "demo/**"
- "tools/**"
- "docs/**"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
script_install:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.7]
torch: [1.9.0]
include:
- torch: 1.9.0
torch_version: torch1.9
torchvision: 0.10.0
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install mmdeploy
run: |
python3 tools/scripts/build_ubuntu_x64_ort.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may verify python -c 'import mmdeploy.apis.onnxruntime as api; assert api.is_available() and api.is_custom_ops_available()'

41 changes: 41 additions & 0 deletions .github/workflows/backend-pplnn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: backend-pplnn

on:
push:
paths-ignore:
- "demo/**"
- "tools/**"

pull_request:
paths-ignore:
- "demo/**"
- "tools/**"
- "docs/**"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
script_install:
runs-on: ubuntu-18.04
strategy:
matrix:
python-version: [3.7]
torch: [1.9.0]
include:
- torch: 1.9.0
torch_version: torch1.9
torchvision: 0.10.0
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install mmdeploy
run: |
python3 tools/scripts/build_ubuntu_x64_pplnn.py
tpoisonooo marked this conversation as resolved.
Show resolved Hide resolved
41 changes: 41 additions & 0 deletions .github/workflows/backend-torchscript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: backend-ort

on:
push:
paths-ignore:
- "demo/**"
- "tools/**"

pull_request:
paths-ignore:
- "demo/**"
- "tools/**"
- "docs/**"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
script_install:
runs-on: ubuntu-18.04
strategy:
matrix:
python-version: [3.7]
torch: [1.9.0]
include:
- torch: 1.9.0
torch_version: torch1.9
torchvision: 0.10.0
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install mmdeploy
run: |
python3 tools/scripts/build_ubuntu_x64_torchscript.py
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Please read [getting_started](docs/en/get_started.md) for the basic usage of MMD

- [Build](docs/en/01-how-to-build/build_from_source.md)
- [Build from Docker](docs/en/01-how-to-build/build_from_docker.md)
- [Build from Script](docs/en/01-how-to-build/build_from_script.md)
- [Build for Linux](docs/en/01-how-to-build/linux-x86_64.md)
- [Build for Win10](docs/en/01-how-to-build/windows.md)
- [Build for Android](docs/en/01-how-to-build/android.md)
Expand Down
1 change: 1 addition & 0 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ MMDeploy 是 [OpenMMLab](https://openmmlab.com/) 模型部署工具箱,**为

- [快速上手](docs/zh_cn/get_started.md)
- [编译](docs/zh_cn/01-how-to-build/build_from_source.md)
- [一键式脚本安装](docs/zh_cn/01-how-to-build/build_from_script.md)
- [Build from Docker](docs/zh_cn/01-how-to-build/build_from_docker.md)
- [Build for Linux](docs/zh_cn/01-how-to-build/linux-x86_64.md)
- [Build for Win10](docs/zh_cn/01-how-to-build/windows.md)
Expand Down
31 changes: 31 additions & 0 deletions docs/en/01-how-to-build/build_from_script.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Build from Script

Through user investigation, we know that most users are already familiar with python and torch before using mmdeploy. Therefore we provide scripts to simplify mmdeploy installation.

Assuming you have a python ready (whether `conda` or `pyenv`), run this script to install mmdeploy + ncnn backend, `nproc` is not compulsory.

```bash
$ cd /path/to/mmdeploy
$ python3 tools/scripts/build_ubuntu_x64_ncnn.py $(nproc)
..
```

A sudo password may be required during this time, and the script will try its best to build and install mmdeploy SDK and demo:

- Detect host OS version, `make` job number, whether use `root` and try to fix `python3 -m pip`
- Find the necessary basic tools, such as g++-7, cmake, wget, etc.
- Compile necessary dependencies, such as pyncnn, protobuf

The script will also try to avoid affecting host environment:

- The dependencies of source code compilation are placed in the `mmdeploy-dep` directory at the same level as mmdeploy
- The script would not modify variables such as PATH, LD_LIBRARY_PATH, PYTHONPATH, etc.

Here is the verified installation script. If you want mmdeploy to support multiple backends at the same time, you can execute each script once:

| script | OS version |
| :-----------------------------: | :---------: |
| build_ubuntu_x64_ncnn.py | 18.04/20.04 |
| build_ubuntu_x64_ort.py | 18.04/20.04 |
| build_ubuntu_x64_pplnn.py | 18.04/20.04 |
| build_ubuntu_x64_torchscript.py | 18.04/20.04 |
2 changes: 1 addition & 1 deletion docs/en/01-how-to-build/build_from_source.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Build From Source
# Build from Source

## Download

Expand Down
17 changes: 17 additions & 0 deletions docs/en/01-how-to-build/linux-x86_64.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,20 @@ You can also activate other engines after the model.

make -j$(nproc) && make install
```

- pplnn

```Bash
cd ${MMDEPLOY_DIR}
mkdir -p build && cd build
cmake .. \
-DCMAKE_CXX_COMPILER=g++-7 \
-DMMDEPLOY_BUILD_SDK=ON \
-DMMDEPLOY_BUILD_EXAMPLES=ON \
-DMMDEPLOY_BUILD_SDK_PYTHON_API=ON \
-DMMDEPLOY_TARGET_DEVICES=cpu \
-DMMDEPLOY_TARGET_BACKENDS=pplnn \
-Dpplnn_DIR=${PPLNN_DIR}/pplnn-build/install/lib/cmake/ppl

make -j$(nproc) && make install
```
1 change: 1 addition & 0 deletions docs/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ You can switch between Chinese and English documents in the lower-left corner of

01-how-to-build/build_from_source.md
01-how-to-build/build_from_docker.md
01-how-to-build/build_from_script.md
01-how-to-build/cmake_option.md

.. toctree::
Expand Down
31 changes: 31 additions & 0 deletions docs/zh_cn/01-how-to-build/build_from_script.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 一键式脚本安装

通过用户调研,我们得知多数使用者在了解 mmdeploy 前,已经熟知 python 和 torch 用法。因此我们提供脚本简化 mmdeploy 安装。

假设您已经准备好 Python3.6 pip 以上环境(无论 conda 或 pyenv),运行这个脚本来安装 mmdeploy + ncnn backend,`nproc` 可以不指定。

```bash
$ cd /path/to/mmdeploy
$ python3 tools/scripts/build_ubuntu_x64_ncnn.py $(nproc)
..
```

期间可能需要 sudo 密码,脚本会尽最大努力完成 mmdeploy SDK 和 demo:

- 检测系统版本、make 使用的 job 个数、是否 root 用户,也会自动修复 pip 问题
- 寻找必须的基础工具,如 g++-7、cmake、wget 等
- 编译必须的依赖,如 pyncnn、 protobuf

脚本也会尽量避免影响 host 环境:

- 源码编译的依赖,都放在与 mmdeploy 同级的 `mmdeploy-dep` 目录中
- 不会主动修改 PATH、LD_LIBRARY_PATH、PYTHONPATH 等变量

这是已验证的安装脚本。如果想让 mmdeploy 同时支持多种 backend,每个脚本执行一次即可:

| script | OS version |
| :-----------------------------: | :---------: |
| build_ubuntu_x64_ncnn.py | 18.04/20.04 |
| build_ubuntu_x64_ort.py | 18.04/20.04 |
| build_ubuntu_x64_pplnn.py | 18.04/20.04 |
| build_ubuntu_x64_torchscript.py | 18.04/20.04 |
4 changes: 2 additions & 2 deletions docs/zh_cn/01-how-to-build/build_from_source.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 源码安装
# 源码手动安装

如果环境允许(网络良好且宿主机强劲),我们建议使用 [docker 方式](build_from_docker.md)
如果网络良好,我们建议使用 [docker](build_from_docker.md) [一键式脚本](build_from_script.md) 方式

## 下载

Expand Down
17 changes: 17 additions & 0 deletions docs/zh_cn/01-how-to-build/linux-x86_64.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,20 @@ pip install -e .

make -j$(nproc) && make install
```

- pplnn

```Bash
cd ${MMDEPLOY_DIR}
mkdir -p build && cd build
cmake .. \
-DCMAKE_CXX_COMPILER=g++-7 \
-DMMDEPLOY_BUILD_SDK=ON \
-DMMDEPLOY_BUILD_EXAMPLES=ON \
-DMMDEPLOY_BUILD_SDK_PYTHON_API=ON \
-DMMDEPLOY_TARGET_DEVICES=cpu \
-DMMDEPLOY_TARGET_BACKENDS=pplnn \
-Dpplnn_DIR=${PPLNN_DIR}/pplnn-build/install/lib/cmake/ppl

make -j$(nproc) && make install
```
1 change: 1 addition & 0 deletions docs/zh_cn/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

01-how-to-build/build_from_source.md
01-how-to-build/build_from_docker.md
01-how-to-build/build_from_script.md
01-how-to-build/cmake_option.md

.. toctree::
Expand Down
Loading