Skip to content

Commit 768aa65

Browse files
CI Support LinuxRelease_aarch64 (#1283)
1 parent 3695849 commit 768aa65

9 files changed

+165
-71
lines changed

.github/workflows/build_and_test.yml

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ jobs:
5353
run: |
5454
python -m pip install --upgrade pip
5555
pip install setuptools wheel auditwheel auditwheel-symbols build
56-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
5756
5857
# Build Paddle2ONNX
5958
- name: Build Paddle2ONNX
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: LinuxRelease_aarch64
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
# python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12']
16+
python-version: [ '3.8']
17+
architecture: [ 'x64' ]
18+
19+
steps:
20+
# Checkout the latest branch of Paddle2ONNX.
21+
- name: Checkout Paddle2ONNX
22+
uses: actions/checkout@v4
23+
with:
24+
submodules: true
25+
26+
# setting up qemu for enabling aarch64 binary execution on x86 machine
27+
- uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
28+
29+
- name: Build on manylinux2014_aarch64
30+
uses: docker://quay.io/pypa/manylinux2014_aarch64:latest
31+
with:
32+
entrypoint: bash
33+
args: .github/workflows/scripts/entrypoint.sh ${{ matrix.python-version }} manylinux2014_aarch64 CentOS
34+
35+
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
36+
with:
37+
name: wheels
38+
path: dist
39+
40+
- name: Publish package
41+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
42+
with:
43+
user: __token__
44+
password: ${{ secrets.ZHENG_BICHENG_PYPI_TOKEN }}

.github/workflows/release_linux_x86_64.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Package
1+
name: LinuxRelease_x86_64
22

33
on:
44
release:
@@ -12,11 +12,10 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12']
15+
# python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12']
16+
python-version: [ '3.8']
1617
architecture: [ 'x64' ]
1718

18-
# For the sake of simplicity in testing, the Paddle2ONNX packaging program will temporarily only package executable files for Python 3.8.
19-
# In the future, we will need to extend support to cover Python 3.8 through Python 3.10.
2019
steps:
2120
# Checkout the latest branch of Paddle2ONNX.
2221
- name: Checkout Paddle2ONNX
@@ -28,7 +27,7 @@ jobs:
2827
uses: docker://quay.io/pypa/manylinux2014_x86_64:latest
2928
with:
3029
entrypoint: bash
31-
args: .github/workflows/scripts/entrypoint.sh ${{ matrix.python-version }} manylinux2014_x86_64
30+
args: .github/workflows/scripts/entrypoint.sh ${{ matrix.python-version }} manylinux2014_x86_64 CentOS
3231

3332
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
3433
with:
@@ -39,4 +38,4 @@ jobs:
3938
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
4039
with:
4140
user: __token__
42-
password: ${{ secrets.ZHENG_BICHENG_PYPI_TOKEN }}
41+
password: ${{ secrets.PADDLE2ONNX_API_TOKEN }}

.github/workflows/scripts/build_protobuf_unix.sh

-22
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Detect the operating system
4+
OS=$(uname -s)
5+
ARCH=$(uname -m)
6+
7+
# Check if the operating system is Linux
8+
if [ "$OS" = "Linux" ]; then
9+
if [[ "$ARCH" == "x86_64" ]]; then
10+
protobuf_tgz_name="protobuf-linux-x64-3.16.0.tgz"
11+
elif [[ "$ARCH" == "arm"* || "$ARCH" == "aarch64" ]]; then
12+
protobuf_tgz_name="protobuf-linux-aarch64-3.16.0.tgz"
13+
else
14+
echo "When the operating system is Linux, the system architecture only supports (x86_64 and aarch64), but the current architecture is $ARCH."
15+
exit 1
16+
fi
17+
# Check if the operating system is Darwin (macOS)
18+
elif [ "$OS" = "Darwin" ]; then
19+
if [[ "$ARCH" == "x86_64" ]]; then
20+
protobuf_tgz_name="protobuf-osx-x86_64-3.16.0.tgz"
21+
elif [[ "$ARCH" == "arm64" ]]; then
22+
protobuf_tgz_name="protobuf-osx-arm64-3.16.0.tgz"
23+
else
24+
echo "When the operating system is Darwin, the system architecture only supports (x86_64 and arm64), but the current architecture is $ARCH."
25+
exit 1
26+
fi
27+
else
28+
echo "The system only supports (Linux and Darwin), but the current system is $OS."
29+
fi
30+
31+
protobuf_url="https://bj.bcebos.com/paddle2onnx/third_party/$protobuf_tgz_name"
32+
wget $protobuf_url
33+
protobuf_svae_dir="$PWD/installed_protobuf"
34+
mkdir -p $protobuf_svae_dir
35+
tar -zxf $protobuf_tgz_name -C $protobuf_svae_dir
36+
export PATH=$protobuf_svae_dir/bin:${PATH}

.github/workflows/scripts/entrypoint.sh

+9-11
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,26 @@ set -e -x
99
# CLI arguments
1010
PY_VERSION=$1
1111
PLAT=$2
12-
GITHUB_EVENT_NAME=$3
12+
SYSTEM_NAME=$3
1313

1414
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
1515

1616
# Compile wheels
1717
# Need to be updated if there is a new Python Version
18-
if [ "$(uname -m)" == "aarch64" ]; then
19-
PIP_INSTALL_COMMAND="$PY_VERSION -m pip install --no-cache-dir -q"
20-
PYTHON_COMMAND="$PY_VERSION"
21-
else
22-
declare -A python_map=( ["3.8"]="cp38-cp38" ["3.9"]="cp39-cp39" ["3.10"]="cp310-cp310" ["3.11"]="cp311-cp311" ["3.12"]="cp312-cp312")
23-
PY_VER=${python_map[$PY_VERSION]}
24-
PIP_INSTALL_COMMAND="/opt/python/${PY_VER}/bin/pip install --no-cache-dir -q"
25-
PYTHON_COMMAND="/opt/python/${PY_VER}/bin/python"
26-
fi
18+
declare -A python_map=( ["3.8"]="cp38-cp38" ["3.9"]="cp39-cp39" ["3.10"]="cp310-cp310" ["3.11"]="cp311-cp311" ["3.12"]="cp312-cp312")
19+
PY_VER=${python_map[$PY_VERSION]}
20+
PIP_INSTALL_COMMAND="/opt/python/${PY_VER}/bin/pip install --no-cache-dir -q"
21+
PYTHON_COMMAND="/opt/python/${PY_VER}/bin/python"
2722

2823
# Update pip and install cmake
2924
$PIP_INSTALL_COMMAND --upgrade pip
3025
$PIP_INSTALL_COMMAND cmake
3126

3227
# Build protobuf from source
33-
source .github/workflows/scripts/build_protobuf_unix.sh "$(nproc)"
28+
if [[ "$SYSTEM_NAME" == "CentOS" ]]; then
29+
yum install -y wget
30+
fi
31+
source .github/workflows/scripts/download_protobuf.sh
3432

3533
# Build Paddle2ONNX wheels
3634
$PYTHON_COMMAND -m build --wheel || { echo "Building wheels failed."; exit 1; }

.gitignore

+14-18
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1+
# System-generated temporary files
12
.DS_Store
23

3-
*~
4+
# Temporary files that may be generated when loading Paddle2ONNX using an IDE
5+
.idea
6+
.vscode
47

5-
*.pyc
6-
.pydevproject
7-
.eggs/*
8-
dist/*
9-
.setuptools*
10-
paddle2onnx.egg-info/*
11-
*.pdmodel
12-
*_*.onnx
13-
*.log
8+
# Files that change dynamically when compiling Paddle2ONNX
149
version.py
1510
paddle2onnx/mappers_registry.h
1611

17-
# CMD
18-
build/*
19-
paddle2onnx-*
20-
21-
# Clion
12+
# Temporary files that may be generated when building Paddle2ONNX
13+
protobuf-*
14+
installed_protobuf
15+
build
2216
cmake-build-*
23-
.idea
17+
paddle2onnx.egg-info/*
18+
dist/*
2419

25-
# VSCode
26-
.vscode
20+
# Temporary files automatically generated when executing Paddle2ONNX unit tests
21+
*.pdmodel
22+
*.onnx

VERSION_NUMBER

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.3
1+
1.2.4

docs/zh/compile_docker.md

+56-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,70 @@
11
# Docker编译安装Paddle2ONNX
22

3-
Paddle2ONNX编译安装需要确保环境满足以下需求
4-
- cmake >= 3.18.0
5-
- protobuf == 3.16.0
3+
## 1 拉取manylinux镜像
64

7-
注意:Paddle2ONNX产出的模型,在使用ONNX Runtime推理时,要求使用最新版本(1.10.0版本以及上),如若需要使用低版本(1.6~1.10之间),则需要将ONNX版本降至1.8.2,在执行完`git submodule update`后,执行如下命令,然后再进行编译
5+
根据系统架构拉取不同的manylinux镜像
6+
7+
```bash
8+
# Pull manylinux2014_x86_64
9+
docker pull quay.io/pypa/manylinux2014_x86_64
10+
docker create --name p2o_build -it quay.io/pypa/manylinux2014_x86_64 /bin/bash
11+
# Pull manylinux2014_x86_64
12+
docker pull quay.io/pypa/manylinux2014_aarch64
13+
docker create --name p2o_build -it quay.io/pypa/manylinux2014_aarch64 /bin/bash
814
```
9-
cd Paddle2ONNX/third/onnx
10-
git checkout v1.8.1
15+
16+
## 2 创建并进入容器
17+
18+
创建并进入 Docker 容器
19+
20+
```bash
21+
docker start p2o_build
22+
docker exec -it p2o_build /bin/bash
1123
```
1224

13-
拉取manylinux镜像并创建容器
25+
## 3 拉取 Paddle2ONNX 仓库
26+
27+
执行以下命令来拉取并初始化 Paddle2ONNX 仓库
1428

1529
```bash
16-
docker pull quay.io/pypa/manylinux2014_x86_64
17-
docker run --name p2o_build -d quay.io/pypa/manylinux2014_x86_64
30+
git clone https://github.com/PaddlePaddle/Paddle2ONNX.git
31+
cd Paddle2ONNX
32+
git submodule init
33+
git submodule update
34+
```
35+
36+
## 4 获取 protobuf 依赖库
37+
38+
### 4.1 使用 protobuf 预编译库
39+
40+
执行以下命令来下载 protobuf 依赖库
41+
42+
```bash
43+
source .github/workflows/scripts/download_protobuf.sh
1844
```
1945

20-
创建容器并运行
46+
### 4.2 下载并编译 protobuf 预编译库
47+
48+
执行以下命令来下载并编译 protobuf 预编译库
2149

2250
```bash
23-
docker start p2o_build
24-
docker exec -it p2o_build bash
51+
git clone https://github.com/protocolbuffers/protobuf.git
52+
cd protobuf
53+
git checkout v3.16.0
54+
mkdir build_source && cd build_source
55+
cmake ../cmake -DCMAKE_INSTALL_PREFIX=${PWD}/installed_protobuf_lib -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
56+
make -j8
57+
make install
58+
59+
# 将编译目录加入环境变量
60+
export PATH=${PWD}/installed_protobuf_lib/bin:${PATH}
2561
```
2662

63+
## 5 执行编译和安装
64+
65+
```bash
66+
/opt/python/cp38-cp38/bin/pip install setuptools wheel auditwheel auditwheel-symbols build
67+
cd /path/to/Paddle2ONNX
68+
/opt/python/cp38-cp38/bin/python -m build
69+
/opt/python/cp38-cp38/bin/pip install dist/*.whl
70+
```

0 commit comments

Comments
 (0)