Skip to content

Commit 4ebb3f2

Browse files
authored
Merge 550bbfc into 34d9bf2
2 parents 34d9bf2 + 550bbfc commit 4ebb3f2

File tree

6 files changed

+248
-47
lines changed

6 files changed

+248
-47
lines changed

.github/workflows/package_tests.yaml

Lines changed: 84 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,94 @@ jobs:
1313
unittest:
1414
strategy:
1515
matrix:
16-
python-version: [3.7, 3.8, 3.9]
17-
platform: [ubuntu-18.04]
18-
include:
19-
- python-version: 3.9
20-
platform: macos-latest
16+
python-version: [3.8]
17+
platform: [linux.2xlarge]
2118
fail-fast: false
2219
runs-on: ${{ matrix.platform }}
2320
steps:
24-
- name: Setup Python ${{ matrix.python-version }}
25-
uses: actions/setup-python@v2
26-
with:
27-
python-version: ${{ matrix.python-version }}
28-
architecture: x64
21+
- name: Update pip
22+
run: |
23+
sudo yum update -y
24+
sudo yum -y install git python3-pip
25+
sudo pip3 install --upgrade pip
26+
- name: Setup conda
27+
run: |
28+
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
29+
bash ~/miniconda.sh -b -p $HOME/miniconda
30+
- name: setup Path
31+
run: |
32+
echo "/home/ec2-user/miniconda/bin" >> $GITHUB_PATH
33+
echo "CONDA=/home/ec2-user/miniconda" >> $GITHUB_PATH
34+
2935
- name: Checkout MultiPy
3036
uses: actions/checkout@v2
31-
- name: Install dependencies
32-
run: |
33-
set -eux
34-
pip install coverage codecov
35-
pip install -r requirements.txt
36-
- name: Run tests
37-
run: coverage run -m unittest discover --verbose --start-directory multipy/test/package/ --pattern "test_*"
38-
- name: Coverage
39-
env:
40-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
37+
with:
38+
submodules: true
39+
- name: Setup SSH (Click me for login details)
40+
uses: ./.github/actions/setup-ssh
41+
with:
42+
github-secret: ${{ secrets.GITHUB_TOKEN }}
43+
- name: Install C++ toolchain
4144
run: |
42-
set -eux
43-
coverage report -m
44-
coverage xml
45+
sudo yum -y install clang llvm
46+
export CC=clang
47+
export CXX=clang++
48+
sudo yum -y install xz-devel bzip2-devel libnsl2-devel readline-devel expat-devel gdbm-devel glibc-devel gmp-devel libffi-devel libGL-devel libX11-devel ncurses-devel openssl-devel sqlite-devel tcl-devel tix-devel tk-devel
49+
sudo yum -y install lzma
50+
sudo yum -y install uuid
51+
sudo yum -y install openmpi-devel
52+
sudo yum -y install zlib-devel
53+
- name: create conda env
54+
run: |
55+
conda create --name multipy_runtime_env python=${{ matrix.python-version }}
56+
conda info
4557
46-
codecov
58+
- name: Install python/pytorch dependencies
59+
shell: bash -l {0}
60+
env:
61+
PYTHON_VERSION: ${{ matrix.python-version }}
62+
run: |
63+
conda run -n multipy_runtime_env python -m pip install astunparse numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses pytest
64+
- name: gen examples
65+
shell: bash -l {0}
66+
env:
67+
PYTHON_VERSION: ${{ matrix.python-version }}
68+
run: |
69+
# A minor hack to get the CI working as conda doesn't have torch,
70+
# fortunately we can remove this once we have a dynamically linked torch
71+
cd multipy/runtime/example
72+
conda create --name example_env python=${{ matrix.python-version }}
73+
conda run -n example_env python -m pip install torch torchvision torchaudio pathlib
74+
conda run -n example_env python generate_examples.py
75+
- name: Build pytorch with ABI=0
76+
shell: bash -l {0}
77+
env:
78+
PYTHON_VERSION: ${{ matrix.python-version }}
79+
run: |
80+
export GLIBCXX_USE_CXX11_ABI=0
81+
export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
82+
export TORCH_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
83+
cd multipy/runtime/third-party/pytorch
84+
export USE_DEPLOY=1
85+
conda run -n multipy_runtime_env python setup.py develop
86+
- name: Build multipy runtime
87+
shell: bash -l {0}
88+
env:
89+
PYTHON_VERSION: ${{ matrix.python-version }}
90+
run: |
91+
cd multipy
92+
cd runtime
93+
mkdir build
94+
cd build
95+
pwd
96+
conda run -n multipy_runtime_env cmake ..
97+
conda run -n multipy_runtime_env cmake --build . --config Release
98+
- name: test_deploy
99+
shell: bash -l {0}
100+
env:
101+
PYTHON_VERSION: ${{ matrix.python-version }}
102+
run: |
103+
cd multipy/runtime
104+
cd build
105+
conda run -n multipy_runtime_env cmake --install . --prefix "."
106+
./test_deploy
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Multipy runtime nightly release + tests with ABI 0
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *' # run at 2 AM UTC
6+
pull_request:
7+
8+
jobs:
9+
unittest:
10+
strategy:
11+
matrix:
12+
python-version: [3.8]
13+
platform: [linux.2xlarge, linux.4xlarge]]
14+
fail-fast: false
15+
runs-on: ${{ matrix.platform }}
16+
steps:
17+
- name: Update pip
18+
run: |
19+
sudo yum update -y
20+
sudo yum -y install git python3-pip
21+
sudo pip3 install --upgrade pip
22+
- name: Setup conda
23+
run: |
24+
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
25+
bash ~/miniconda.sh -b -p $HOME/miniconda
26+
- name: setup Path
27+
run: |
28+
echo "/home/ec2-user/miniconda/bin" >> $GITHUB_PATH
29+
echo "CONDA=/home/ec2-user/miniconda" >> $GITHUB_PATH
30+
31+
- name: Checkout MultiPy
32+
uses: actions/checkout@v2
33+
with:
34+
submodules: true
35+
- name: Setup SSH (Click me for login details)
36+
uses: ./.github/actions/setup-ssh
37+
with:
38+
github-secret: ${{ secrets.GITHUB_TOKEN }}
39+
- name: Install C++ toolchain
40+
run: |
41+
sudo yum -y install clang llvm
42+
export CC=clang
43+
export CXX=clang++
44+
sudo yum -y install xz-devel bzip2-devel libnsl2-devel readline-devel expat-devel gdbm-devel glibc-devel gmp-devel libffi-devel libGL-devel libX11-devel ncurses-devel openssl-devel sqlite-devel tcl-devel tix-devel tk-devel
45+
sudo yum -y install lzma
46+
sudo yum -y install uuid
47+
sudo yum -y install openmpi-devel
48+
sudo yum -y install zlib-devel
49+
- name: create conda env
50+
run: |
51+
conda create --name multipy_runtime_env python=${{ matrix.python-version }}
52+
conda info
53+
54+
- name: Install python/pytorch dependencies
55+
shell: bash -l {0}
56+
env:
57+
PYTHON_VERSION: ${{ matrix.python-version }}
58+
run: |
59+
conda run -n multipy_runtime_env python -m pip install astunparse numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses pytest
60+
- name: gen examples
61+
shell: bash -l {0}
62+
env:
63+
PYTHON_VERSION: ${{ matrix.python-version }}
64+
run: |
65+
# A minor hack to get the CI working as conda doesn't have torch,
66+
# fortunately we can remove this once we have a dynamically linked torch
67+
cd multipy/runtime/example
68+
conda create --name example_env python=${{ matrix.python-version }}
69+
conda run -n example_env python -m pip install torch torchvision torchaudio pathlib
70+
conda run -n example_env python generate_examples.py
71+
- name: Build pytorch with ABI=0
72+
shell: bash -l {0}
73+
env:
74+
PYTHON_VERSION: ${{ matrix.python-version }}
75+
run: |
76+
export GLIBCXX_USE_CXX11_ABI=0
77+
export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
78+
export TORCH_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
79+
cd multipy/runtime/third-party/pytorch
80+
export USE_DEPLOY=1
81+
conda run -n multipy_runtime_env python setup.py develop
82+
- name: Build multipy runtime
83+
shell: bash -l {0}
84+
env:
85+
PYTHON_VERSION: ${{ matrix.python-version }}
86+
run: |
87+
cd multipy
88+
cd runtime
89+
mkdir build
90+
cd build
91+
pwd
92+
conda run -n multipy_runtime_env cmake -DABI_EQUALS_1=OFF ..
93+
conda run -n multipy_runtime_env cmake --build . --config Release
94+
- name: test_deploy
95+
shell: bash -l {0}
96+
env:
97+
PYTHON_VERSION: ${{ matrix.python-version }}
98+
run: |
99+
cd multipy/runtime
100+
cd build
101+
conda run -n multipy_runtime_env cmake --install . --prefix "."
102+
./test_deploy
103+
- name: create tarball [click me to get a list of files for the nightly release]
104+
shell: bash -l {0}
105+
env:
106+
PYTHON_VERSION: ${{ matrix.python-version }}
107+
run: |
108+
cd multipy/runtime/build/dist
109+
tar -czvf multipy_runtime.tar.gz runtime/
110+
111+
- name: Update nightly release
112+
uses: pyTooling/Actions/releaser@main
113+
with:
114+
tag: nightly-runtime
115+
rm: true
116+
token: ${{ secrets.GITHUB_TOKEN }}
117+
files: |
118+
multipy/runtime/build/dist/multipy_runtime.tar.gz

.github/workflows/runtime_nightly.yaml renamed to .github/workflows/runtime_nightly_abi_1.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
name: Multipy runtime nightly release + tests
1+
name: Multipy runtime nightly release + tests with ABI 1
22

33
on:
44
schedule:
55
- cron: '0 2 * * *' # run at 2 AM UTC
6+
pull_request:
67

78
jobs:
89
unittest:
910
strategy:
1011
matrix:
1112
python-version: [3.8]
12-
platform: [linux.2xlarge]
13+
platform: [linux.2xlarge, linux.4xlarge]
1314
fail-fast: false
1415
runs-on: ${{ matrix.platform }}
1516
steps:
@@ -72,6 +73,9 @@ jobs:
7273
env:
7374
PYTHON_VERSION: ${{ matrix.python-version }}
7475
run: |
76+
export GLIBCXX_USE_CXX11_ABI=1
77+
export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=1"
78+
export TORCH_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=1"
7579
cd multipy/runtime/third-party/pytorch
7680
export USE_DEPLOY=1
7781
conda run -n multipy_runtime_env python setup.py develop
@@ -85,16 +89,16 @@ jobs:
8589
mkdir build
8690
cd build
8791
pwd
88-
conda run -n multipy_runtime_env cmake ..
92+
conda run -n multipy_runtime_env cmake -DABI_EQUALS_1=ON ..
8993
conda run -n multipy_runtime_env cmake --build . --config Release
90-
conda run -n multipy_runtime_env cmake --install . --prefix "."
9194
- name: test_deploy
9295
shell: bash -l {0}
9396
env:
9497
PYTHON_VERSION: ${{ matrix.python-version }}
9598
run: |
9699
cd multipy/runtime
97100
cd build
101+
conda run -n multipy_runtime_env cmake --install . --prefix "."
98102
./test_deploy
99103
- name: create tarball [click me to get a list of files for the nightly release]
100104
shell: bash -l {0}
@@ -107,7 +111,7 @@ jobs:
107111
- name: Update nightly release
108112
uses: pyTooling/Actions/releaser@main
109113
with:
110-
tag: nightly-runtime
114+
tag: nightly-runtime-ABI-is-1
111115
rm: true
112116
token: ${{ secrets.GITHUB_TOKEN }}
113117
files: |

.github/workflows/runtime_tests.yaml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
name: Runtime Unittests
1+
name: Multipy unit tests
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
4+
workflow_call:
5+
inputs:
6+
abi_0:
7+
required: false
8+
default: True
9+
type: boolean
810

911
jobs:
1012
unittest:
1113
strategy:
1214
matrix:
1315
python-version: [3.8]
14-
platform: [linux.2xlarge]
16+
platform: [linux.2xlarge, linux.4xlarge]]
1517
fail-fast: false
1618
runs-on: ${{ matrix.platform }}
1719
steps:
@@ -74,6 +76,9 @@ jobs:
7476
env:
7577
PYTHON_VERSION: ${{ matrix.python-version }}
7678
run: |
79+
export GLIBCXX_USE_CXX11_ABI=0
80+
export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
81+
export TORCH_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
7782
cd multipy/runtime/third-party/pytorch
7883
export USE_DEPLOY=1
7984
conda run -n multipy_runtime_env python setup.py develop
@@ -82,16 +87,19 @@ jobs:
8287
env:
8388
PYTHON_VERSION: ${{ matrix.python-version }}
8489
run: |
85-
cd multipy/runtime
90+
cd multipy
91+
cd runtime
8692
mkdir build
8793
cd build
88-
conda run -n multipy_runtime_env cmake ..
94+
pwd
95+
conda run -n multipy_runtime_env cmake -DABI_EQUALS_1=OFF ..
8996
conda run -n multipy_runtime_env cmake --build . --config Release
90-
conda run -n multipy_runtime_env cmake --install . --prefix "."
91-
- name: Run test_deploy
97+
- name: test_deploy
9298
shell: bash -l {0}
9399
env:
94100
PYTHON_VERSION: ${{ matrix.python-version }}
95101
run: |
96-
cd multipy/runtime/build
102+
cd multipy/runtime
103+
cd build
104+
conda run -n multipy_runtime_env cmake --install . --prefix "."
97105
./test_deploy

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internally, please see the related [arXiv paper](https://arxiv.org/pdf/2104.0025
1111

1212
## Installation
1313
### Installing `multipy::runtime`
14-
`libtorch_interpreter.so`,`libtorch_deploy.a`, `utils.cmake`, and the header files of `multipy::runtime` can be installed from our [nightly release](https://github.com/pytorch/multipy/releases/download/nightly/multipy_runtime.tar.gz)
14+
`libtorch_interpreter.so`,`libtorch_deploy.a`, `utils.cmake`, and the header files of `multipy::runtime` can be installed from our [nightly release](https://github.com/pytorch/multipy/releases/tag/nightly-runtime) (by default the ABI for the nightly release is 0), you can find a version of the release with ABI=1 [here](https://github.com/pytorch/multipy/releases/tag/nightly-runtime-ABI-is-1).
1515

1616
In order to run pytorch models, we need to use libtorch which can be setup using the instructions [here](https://pytorch.org/cppdocs/installing.html)
1717

@@ -29,13 +29,21 @@ git submodule sync && git submodule update --init --recursive
2929
cd multipy/MultiPy/runtime
3030

3131
# Currently multipy::runtime requires that we build pytorch from source since we need to expose some objects in torch (ie. torch_python, etc.) for multipy::runtime to work.
32+
33+
# Furthermore, by defualt pytorch is built with ABI = 1, so we change it to 0. Remove the following three lines if you want ABI=1.
34+
35+
export GLIBCXX_USE_CXX11_ABI=0
36+
export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
37+
export TORCH_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
38+
3239
cd ../pytorch
3340
USE_DEPLOY=1 python setup.py develop
3441
cd ../..
3542

3643
# build runtime
3744
mkdir build
3845
cd build
46+
# use cmake -DABI_EQUALS_1=ON .. instead if you want ABI=1
3947
cmake ..
4048
cmake --build . --config Release
4149

0 commit comments

Comments
 (0)