Skip to content

Commit 8a40a97

Browse files
authored
Merge 66b0ebb into 80fd3b3
2 parents 80fd3b3 + 66b0ebb commit 8a40a97

File tree

6 files changed

+294
-12
lines changed

6 files changed

+294
-12
lines changed
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Multipy runtime nightly release with cuda
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *' # run at 2 AM UTC
6+
pull_request:
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
unittest:
13+
strategy:
14+
matrix:
15+
python-version: [3.8]
16+
platform: [linux.4xlarge.nvidia.gpu]
17+
abi: [0,1]
18+
fail-fast: false
19+
runs-on: ${{ matrix.platform }}
20+
steps:
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+
27+
- name: Setup conda
28+
run: |
29+
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
30+
bash ~/miniconda.sh -b -p $HOME/miniconda
31+
32+
- name: setup Path
33+
run: |
34+
echo /usr/local/cuda-11.3/bin >> $GITHUB_PATH
35+
echo "/home/ec2-user/miniconda/bin" >> $GITHUB_PATH
36+
echo "CONDA=/home/ec2-user/miniconda" >> $GITHUB_PATH
37+
38+
- name: Checkout MultiPy
39+
uses: actions/checkout@v2
40+
with:
41+
submodules: true
42+
43+
- name: Setup SSH (Click me for login details)
44+
uses: ./.github/actions/setup-ssh
45+
with:
46+
github-secret: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Install C++ toolchain
49+
run: |
50+
sudo yum -y install clang llvm
51+
export CC=clang
52+
export CXX=clang++
53+
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
54+
sudo yum -y install lzma
55+
sudo yum -y install uuid
56+
sudo yum -y install openmpi-devel
57+
sudo yum -y install zlib-devel
58+
59+
- name: create conda env
60+
run: |
61+
conda create --name multipy_runtime_env python=${{ matrix.python-version }}
62+
conda info
63+
64+
- name: Install python/pytorch dependencies
65+
shell: bash -l {0}
66+
env:
67+
PYTHON_VERSION: ${{ matrix.python-version }}
68+
run: |
69+
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
70+
71+
- name: gen examples
72+
shell: bash -l {0}
73+
env:
74+
PYTHON_VERSION: ${{ matrix.python-version }}
75+
run: |
76+
# A minor hack to get the CI working as conda doesn't have torch,
77+
# fortunately we can remove this once we have a dynamically linked torch
78+
cd multipy/runtime/example
79+
conda create --name example_env python=${{ matrix.python-version }}
80+
conda run -n example_env python -m pip install torch torchvision torchaudio pathlib
81+
conda run -n example_env python generate_examples.py
82+
83+
- name: Build pytorch with ABI=${{ matrix.abi }}
84+
shell: bash -l {0}
85+
env:
86+
PYTHON_VERSION: ${{ matrix.python-version }}
87+
run: |
88+
export GLIBCXX_USE_CXX11_ABI=${{ matrix.abi }}
89+
export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=${{ matrix.abi }}"
90+
export TORCH_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=${{ matrix.abi }}"
91+
cd multipy/runtime/third-party/pytorch
92+
export USE_DEPLOY=1
93+
export USE_CUDA=1
94+
conda run -n multipy_runtime_env python setup.py develop
95+
96+
- name: Build multipy runtime with ABI=${{ matrix.abi }}
97+
shell: bash -l {0}
98+
env:
99+
PYTHON_VERSION: ${{ matrix.python-version }}
100+
run: |
101+
cd multipy/runtime
102+
mkdir build
103+
cd build
104+
conda run -n multipy_runtime_env cmake -DABI_EQUALS_1=${{ matrix.abi }} ..
105+
conda run -n multipy_runtime_env cmake --build . --config Release
106+
107+
- name: install files
108+
shell: bash -l {0}
109+
env:
110+
PYTHON_VERSION: ${{ matrix.python-version }}
111+
run: |
112+
cd multipy/runtime/build
113+
conda run -n multipy_runtime_env cmake --install . --prefix "."
114+
115+
- name: Run unit tests with ABI=${{ matrix.abi }}
116+
shell: bash -l {0}
117+
env:
118+
PYTHON_VERSION: ${{ matrix.python-version }}
119+
run: |
120+
cd multipy/runtime/build
121+
./test_deploy
122+
123+
- name: Run unit tests with ABI=${{ matrix.abi }} with gpu
124+
shell: bash -l {0}
125+
env:
126+
PYTHON_VERSION: ${{ matrix.python-version }}
127+
run: |
128+
cd multipy/runtime/build
129+
./test_deploy_gpu
130+
131+
- name: create tarball [click me to get a list of files for the nightly release]
132+
shell: bash -l {0}
133+
env:
134+
PYTHON_VERSION: ${{ matrix.python-version }}
135+
run: |
136+
cd multipy/runtime/build/dist
137+
tar -czvf multipy_runtime.tar.gz multipy/
138+
139+
- name: Update nightly release
140+
uses: pyTooling/Actions/releaser@main
141+
with:
142+
tag: nightly-runtime-cuda-abi-${{ matrix.abi }}
143+
rm: true
144+
token: ${{ secrets.GITHUB_TOKEN }}
145+
files: |
146+
multipy/runtime/build/dist/multipy_runtime.tar.gz

.github/workflows/runtime_tests.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ jobs:
110110
conda run -n multipy_runtime_env cmake --install . --prefix "."
111111
112112
- name: Run unit tests with ABI=${{ matrix.abi }}
113-
if: ${{ matrix.abi }} == 1
114113
shell: bash -l {0}
115114
env:
116115
PYTHON_VERSION: ${{ matrix.python-version }}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Multipy runtime tests with cuda
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
unittest:
11+
strategy:
12+
matrix:
13+
python-version: [3.7, 3.8, 3.9]
14+
platform: [linux.4xlarge.nvidia.gpu]
15+
abi: [0,1]
16+
fail-fast: false
17+
runs-on: ${{ matrix.platform }}
18+
steps:
19+
- name: Update pip
20+
run: |
21+
sudo yum update -y
22+
sudo yum -y install git python3-pip
23+
sudo pip3 install --upgrade pip
24+
25+
- name: Setup conda
26+
run: |
27+
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
28+
bash ~/miniconda.sh -b -p $HOME/miniconda
29+
30+
- name: Install CUDA 11.3
31+
shell: bash
32+
run: |
33+
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
34+
sudo yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo
35+
sudo yum clean expire-cache
36+
sudo yum install -y nvidia-driver-latest-dkms
37+
sudo yum install -y cuda-11-3
38+
sudo yum install -y cuda-drivers
39+
sudo yum install -y libcudnn8-devel
40+
41+
- name: setup Path
42+
run: |
43+
echo /usr/local/cuda-11.3/bin >> $GITHUB_PATH
44+
echo "/home/ec2-user/miniconda/bin" >> $GITHUB_PATH
45+
echo "CONDA=/home/ec2-user/miniconda" >> $GITHUB_PATH
46+
47+
- name: Checkout MultiPy
48+
uses: actions/checkout@v2
49+
with:
50+
submodules: true
51+
52+
- name: Setup SSH (Click me for login details)
53+
uses: ./.github/actions/setup-ssh
54+
with:
55+
github-secret: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- name: Install C++ toolchain
58+
run: |
59+
sudo yum -y install clang llvm
60+
export CC=clang
61+
export CXX=clang++
62+
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
63+
sudo yum -y install lzma
64+
sudo yum -y install uuid
65+
sudo yum -y install openmpi-devel
66+
sudo yum -y install zlib-devel
67+
68+
- name: create conda env
69+
run: |
70+
conda create --name multipy_runtime_env python=${{ matrix.python-version }}
71+
conda info
72+
73+
- name: Install python/pytorch dependencies
74+
shell: bash -l {0}
75+
env:
76+
PYTHON_VERSION: ${{ matrix.python-version }}
77+
run: |
78+
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
79+
80+
- name: gen examples
81+
shell: bash -l {0}
82+
env:
83+
PYTHON_VERSION: ${{ matrix.python-version }}
84+
run: |
85+
# A minor hack to get the CI working as conda doesn't have torch,
86+
# fortunately we can remove this once we have a dynamically linked torch
87+
cd multipy/runtime/example
88+
conda create --name example_env python=${{ matrix.python-version }}
89+
conda run -n example_env python -m pip install torch torchvision torchaudio pathlib
90+
conda run -n example_env python generate_examples.py
91+
92+
- name: Build pytorch with ABI=${{ matrix.abi }}
93+
shell: bash -l {0}
94+
env:
95+
PYTHON_VERSION: ${{ matrix.python-version }}
96+
run: |
97+
export GLIBCXX_USE_CXX11_ABI=${{ matrix.abi }}
98+
export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=${{ matrix.abi }}"
99+
export TORCH_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=${{ matrix.abi }}"
100+
cd multipy/runtime/third-party/pytorch
101+
export USE_DEPLOY=1
102+
export USE_CUDA=1
103+
conda run -n multipy_runtime_env python setup.py develop
104+
105+
- name: Build multipy runtime with ABI=${{ matrix.abi }}
106+
shell: bash -l {0}
107+
env:
108+
PYTHON_VERSION: ${{ matrix.python-version }}
109+
run: |
110+
cd multipy/runtime
111+
mkdir build
112+
cd build
113+
conda run -n multipy_runtime_env cmake -DABI_EQUALS_1=${{ matrix.abi }} ..
114+
conda run -n multipy_runtime_env cmake --build . --config Release
115+
116+
- name: install files
117+
shell: bash -l {0}
118+
env:
119+
PYTHON_VERSION: ${{ matrix.python-version }}
120+
run: |
121+
cd multipy/runtime/build
122+
conda run -n multipy_runtime_env cmake --install . --prefix "."
123+
124+
- name: Run unit tests with ABI=${{ matrix.abi }}
125+
shell: bash -l {0}
126+
env:
127+
PYTHON_VERSION: ${{ matrix.python-version }}
128+
run: |
129+
cd multipy/runtime/build
130+
./test_deploy
131+
132+
- name: Run unit tests with ABI=${{ matrix.abi }} with gpu
133+
shell: bash -l {0}
134+
env:
135+
PYTHON_VERSION: ${{ matrix.python-version }}
136+
run: |
137+
cd multipy/runtime/build
138+
./test_deploy_gpu

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ internally, please see the related [arXiv paper](https://arxiv.org/pdf/2104.0025
1515

1616
The C++ binaries (`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-abi-0). 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-1).
1717

18+
C++ binaries with cuda (11.3) support can also be found for [ABI=0](https://github.com/pytorch/multipy/releases/tag/nightly-runtime-cuda-abi-0) and [ABI=1](https://github.com/pytorch/multipy/releases/tag/nightly-runtime-cuda-abi-1)
19+
1820
```
1921
wget https://github.com/pytorch/multipy/releases/download/nightly-runtime-abi-0/multipy_runtime.tar.gz
2022
tar -xvzf multipy_runtime.tar.gz

multipy/runtime/CMakeLists.txt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,12 @@ target_link_libraries(test_deploy
8686
)
8787
target_include_directories(test_deploy PRIVATE ${CMAKE_SOURCE_DIR}/../..)
8888

89-
# LINK_DIRECTORIES("${PYTORCH_ROOT}/torch/lib")
90-
# add_executable(test_deploy_gpu ${INTERPRETER_TEST_SOURCES_GPU})
91-
# target_compile_definitions(test_deploy_gpu PUBLIC TEST_CUSTOM_LIBRARY)
92-
# target_include_directories(test_deploy_gpu PRIVATE ${PYTORCH_ROOT}/torch)
93-
# target_include_directories(test_deploy_gpu PRIVATE ${CMAKE_SOURCE_DIR}/../..)
94-
# target_link_libraries(test_deploy_gpu
95-
# PUBLIC "-Wl,--no-as-needed -rdynamic" gtest dl torch_deploy_interface c10 torch_cpu
96-
# )
89+
LINK_DIRECTORIES("${PYTORCH_ROOT}/torch/lib")
90+
add_executable(test_deploy_gpu ${INTERPRETER_TEST_SOURCES_GPU})
91+
target_compile_definitions(test_deploy_gpu PUBLIC TEST_CUSTOM_LIBRARY)
92+
target_include_directories(test_deploy_gpu PRIVATE ${PYTORCH_ROOT}/torch)
93+
target_include_directories(test_deploy_gpu PRIVATE ${CMAKE_SOURCE_DIR}/../..)
94+
target_link_libraries(test_deploy_gpu PUBLIC "-Wl,--no-as-needed -rdynamic" gtest dl torch_deploy_interface c10 torch_cpu)
9795

9896
LINK_DIRECTORIES("${PYTORCH_ROOT}/torch/lib")
9997
add_library(test_deploy_lib SHARED test_deploy_lib.cpp)
@@ -119,7 +117,7 @@ target_link_libraries(interactive_embedded_interpreter
119117
)
120118

121119
install(TARGETS test_deploy DESTINATION tests/bin)
122-
# install(TARGETS test_deploy_gpu DESTINATION tests/bin)
120+
install(TARGETS test_deploy_gpu DESTINATION tests/bin)
123121

124122
install(TARGETS test_deploy DESTINATION tests/bin)
125123

multipy/runtime/test_deploy_gpu.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ TEST(TorchDeployGPUTest, SimpleModel) {
6363

6464
TEST(TorchDeployGPUTest, UsesDistributed) {
6565
const auto model_filename = path(
66-
"USES_DISTRIBUTED",
67-
"torch/csrc/deploy/example/generated/uses_distributed");
66+
"USES_DISTRIBUTED", "multipy/runtime/example/generated/uses_distributed");
6867
torch::deploy::InterpreterManager m(1);
6968
torch::deploy::Package p = m.loadPackage(model_filename);
7069
{

0 commit comments

Comments
 (0)