Skip to content

Commit

Permalink
Merge 550bbfc into 34d9bf2
Browse files Browse the repository at this point in the history
  • Loading branch information
PaliC authored Jun 21, 2022
2 parents 34d9bf2 + 550bbfc commit 4ebb3f2
Show file tree
Hide file tree
Showing 6 changed files with 248 additions and 47 deletions.
108 changes: 84 additions & 24 deletions .github/workflows/package_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,94 @@ jobs:
unittest:
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
platform: [ubuntu-18.04]
include:
- python-version: 3.9
platform: macos-latest
python-version: [3.8]
platform: [linux.2xlarge]
fail-fast: false
runs-on: ${{ matrix.platform }}
steps:
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Update pip
run: |
sudo yum update -y
sudo yum -y install git python3-pip
sudo pip3 install --upgrade pip
- name: Setup conda
run: |
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
- name: setup Path
run: |
echo "/home/ec2-user/miniconda/bin" >> $GITHUB_PATH
echo "CONDA=/home/ec2-user/miniconda" >> $GITHUB_PATH
- name: Checkout MultiPy
uses: actions/checkout@v2
- name: Install dependencies
run: |
set -eux
pip install coverage codecov
pip install -r requirements.txt
- name: Run tests
run: coverage run -m unittest discover --verbose --start-directory multipy/test/package/ --pattern "test_*"
- name: Coverage
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
submodules: true
- name: Setup SSH (Click me for login details)
uses: ./.github/actions/setup-ssh
with:
github-secret: ${{ secrets.GITHUB_TOKEN }}
- name: Install C++ toolchain
run: |
set -eux
coverage report -m
coverage xml
sudo yum -y install clang llvm
export CC=clang
export CXX=clang++
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
sudo yum -y install lzma
sudo yum -y install uuid
sudo yum -y install openmpi-devel
sudo yum -y install zlib-devel
- name: create conda env
run: |
conda create --name multipy_runtime_env python=${{ matrix.python-version }}
conda info
codecov
- name: Install python/pytorch dependencies
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
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
- name: gen examples
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
# A minor hack to get the CI working as conda doesn't have torch,
# fortunately we can remove this once we have a dynamically linked torch
cd multipy/runtime/example
conda create --name example_env python=${{ matrix.python-version }}
conda run -n example_env python -m pip install torch torchvision torchaudio pathlib
conda run -n example_env python generate_examples.py
- name: Build pytorch with ABI=0
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
export GLIBCXX_USE_CXX11_ABI=0
export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
export TORCH_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
cd multipy/runtime/third-party/pytorch
export USE_DEPLOY=1
conda run -n multipy_runtime_env python setup.py develop
- name: Build multipy runtime
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
cd multipy
cd runtime
mkdir build
cd build
pwd
conda run -n multipy_runtime_env cmake ..
conda run -n multipy_runtime_env cmake --build . --config Release
- name: test_deploy
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
cd multipy/runtime
cd build
conda run -n multipy_runtime_env cmake --install . --prefix "."
./test_deploy
118 changes: 118 additions & 0 deletions .github/workflows/runtime_nightly_abi_0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Multipy runtime nightly release + tests with ABI 0

on:
schedule:
- cron: '0 2 * * *' # run at 2 AM UTC
pull_request:

jobs:
unittest:
strategy:
matrix:
python-version: [3.8]
platform: [linux.2xlarge, linux.4xlarge]]
fail-fast: false
runs-on: ${{ matrix.platform }}
steps:
- name: Update pip
run: |
sudo yum update -y
sudo yum -y install git python3-pip
sudo pip3 install --upgrade pip
- name: Setup conda
run: |
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
- name: setup Path
run: |
echo "/home/ec2-user/miniconda/bin" >> $GITHUB_PATH
echo "CONDA=/home/ec2-user/miniconda" >> $GITHUB_PATH
- name: Checkout MultiPy
uses: actions/checkout@v2
with:
submodules: true
- name: Setup SSH (Click me for login details)
uses: ./.github/actions/setup-ssh
with:
github-secret: ${{ secrets.GITHUB_TOKEN }}
- name: Install C++ toolchain
run: |
sudo yum -y install clang llvm
export CC=clang
export CXX=clang++
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
sudo yum -y install lzma
sudo yum -y install uuid
sudo yum -y install openmpi-devel
sudo yum -y install zlib-devel
- name: create conda env
run: |
conda create --name multipy_runtime_env python=${{ matrix.python-version }}
conda info
- name: Install python/pytorch dependencies
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
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
- name: gen examples
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
# A minor hack to get the CI working as conda doesn't have torch,
# fortunately we can remove this once we have a dynamically linked torch
cd multipy/runtime/example
conda create --name example_env python=${{ matrix.python-version }}
conda run -n example_env python -m pip install torch torchvision torchaudio pathlib
conda run -n example_env python generate_examples.py
- name: Build pytorch with ABI=0
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
export GLIBCXX_USE_CXX11_ABI=0
export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
export TORCH_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
cd multipy/runtime/third-party/pytorch
export USE_DEPLOY=1
conda run -n multipy_runtime_env python setup.py develop
- name: Build multipy runtime
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
cd multipy
cd runtime
mkdir build
cd build
pwd
conda run -n multipy_runtime_env cmake -DABI_EQUALS_1=OFF ..
conda run -n multipy_runtime_env cmake --build . --config Release
- name: test_deploy
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
cd multipy/runtime
cd build
conda run -n multipy_runtime_env cmake --install . --prefix "."
./test_deploy
- name: create tarball [click me to get a list of files for the nightly release]
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
cd multipy/runtime/build/dist
tar -czvf multipy_runtime.tar.gz runtime/
- name: Update nightly release
uses: pyTooling/Actions/releaser@main
with:
tag: nightly-runtime
rm: true
token: ${{ secrets.GITHUB_TOKEN }}
files: |
multipy/runtime/build/dist/multipy_runtime.tar.gz
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name: Multipy runtime nightly release + tests
name: Multipy runtime nightly release + tests with ABI 1

on:
schedule:
- cron: '0 2 * * *' # run at 2 AM UTC
pull_request:

jobs:
unittest:
strategy:
matrix:
python-version: [3.8]
platform: [linux.2xlarge]
platform: [linux.2xlarge, linux.4xlarge]
fail-fast: false
runs-on: ${{ matrix.platform }}
steps:
Expand Down Expand Up @@ -72,6 +73,9 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
export GLIBCXX_USE_CXX11_ABI=1
export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=1"
export TORCH_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=1"
cd multipy/runtime/third-party/pytorch
export USE_DEPLOY=1
conda run -n multipy_runtime_env python setup.py develop
Expand All @@ -85,16 +89,16 @@ jobs:
mkdir build
cd build
pwd
conda run -n multipy_runtime_env cmake ..
conda run -n multipy_runtime_env cmake -DABI_EQUALS_1=ON ..
conda run -n multipy_runtime_env cmake --build . --config Release
conda run -n multipy_runtime_env cmake --install . --prefix "."
- name: test_deploy
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
cd multipy/runtime
cd build
conda run -n multipy_runtime_env cmake --install . --prefix "."
./test_deploy
- name: create tarball [click me to get a list of files for the nightly release]
shell: bash -l {0}
Expand All @@ -107,7 +111,7 @@ jobs:
- name: Update nightly release
uses: pyTooling/Actions/releaser@main
with:
tag: nightly-runtime
tag: nightly-runtime-ABI-is-1
rm: true
token: ${{ secrets.GITHUB_TOKEN }}
files: |
Expand Down
30 changes: 19 additions & 11 deletions .github/workflows/runtime_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: Runtime Unittests
name: Multipy unit tests

on:
push:
branches:
- main
pull_request:
workflow_call:
inputs:
abi_0:
required: false
default: True
type: boolean

jobs:
unittest:
strategy:
matrix:
python-version: [3.8]
platform: [linux.2xlarge]
platform: [linux.2xlarge, linux.4xlarge]]
fail-fast: false
runs-on: ${{ matrix.platform }}
steps:
Expand Down Expand Up @@ -74,6 +76,9 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
export GLIBCXX_USE_CXX11_ABI=0
export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
export TORCH_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
cd multipy/runtime/third-party/pytorch
export USE_DEPLOY=1
conda run -n multipy_runtime_env python setup.py develop
Expand All @@ -82,16 +87,19 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
cd multipy/runtime
cd multipy
cd runtime
mkdir build
cd build
conda run -n multipy_runtime_env cmake ..
pwd
conda run -n multipy_runtime_env cmake -DABI_EQUALS_1=OFF ..
conda run -n multipy_runtime_env cmake --build . --config Release
conda run -n multipy_runtime_env cmake --install . --prefix "."
- name: Run test_deploy
- name: test_deploy
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
cd multipy/runtime/build
cd multipy/runtime
cd build
conda run -n multipy_runtime_env cmake --install . --prefix "."
./test_deploy
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internally, please see the related [arXiv paper](https://arxiv.org/pdf/2104.0025

## Installation
### Installing `multipy::runtime`
`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)
`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).

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)

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

# 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.

# 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.

export GLIBCXX_USE_CXX11_ABI=0
export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
export TORCH_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"

cd ../pytorch
USE_DEPLOY=1 python setup.py develop
cd ../..

# build runtime
mkdir build
cd build
# use cmake -DABI_EQUALS_1=ON .. instead if you want ABI=1
cmake ..
cmake --build . --config Release

Expand Down
Loading

0 comments on commit 4ebb3f2

Please sign in to comment.