Repository navigation
203 lines (184 loc) · 7.82 KB
/
Copy pathbuild-onnxruntime.yml
File metadata and controls
203 lines (184 loc) · 7.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# This workflow is based on: https://github.com/microsoft/onnxruntime/blob/v1.29.0/tools/ci_build/github/azure-pipelines/templates/py-linux.yml
# plus build_linux_python_package.sh / run_python_tests.sh, which it drives in-container.
name: Build onnxruntime wheels (riscv64)
on:
workflow_dispatch:
inputs:
version:
description: 'Version glob to (re)build; empty builds every version of docs/packages/onnxruntime.yaml not released yet'
required: false
default: ''
pull_request:
branches: [main]
paths:
- '.github/workflows/build-onnxruntime.yml'
- 'docs/packages/onnxruntime.yaml'
push:
branches: [main]
paths:
- '.github/workflows/build-onnxruntime.yml'
- 'docs/packages/onnxruntime.yaml'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
env:
# Upstream's AzureCR build image isn't public; manylinux is the closest equivalent.
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
jobs:
setup:
uses: $/.github/workflows/_setup.yml
with:
package: onnxruntime
version: ${{ inputs.version }}
build_wheels:
needs: [setup]
if: needs.setup.outputs.versions != '[]'
name: Build onnxruntime ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
timeout-minutes: 1440 # 24h
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
# onnxruntime is not abi3: upstream publishes one wheel per interpreter.
python: ["cp312", "cp313", "cp314", "cp314t"]
exclude:
# 1.30.0 aborts riscv64 cp314t in onnxruntime_test_python.py with a heap-corruption
# SIGABRT ("malloc(): unaligned tcache chunk detected"); 1.29.0 built/tested clean
# on cp314t riscv64, so this is a regression to re-check on the next version bump.
- version: "1.30.0"
python: cp314t
env:
ONNXRUNTIME_VERSION: ${{ matrix.version }}
steps:
- name: Checkout onnxruntime v${{ env.ONNXRUNTIME_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: microsoft/onnxruntime
ref: v${{ env.ONNXRUNTIME_VERSION }}
submodules: none
persist-credentials: false
- name: Write container script
run: |
mkdir -p build
cat > riscv64-build-and-test.sh <<'EOF'
#!/bin/bash
set -e -x
case "${PYTHON_TAG}" in
*t) python_dir="/opt/python/${PYTHON_TAG%t}-${PYTHON_TAG}/bin" ;;
*) python_dir="/opt/python/${PYTHON_TAG}-${PYTHON_TAG}/bin" ;;
esac
# Upstream prepends it too: some dependency CMakeLists invoke a bare `python3`.
export PATH="${python_dir}:${PATH}"
python_exe="${python_dir}/python"
# Several FetchContent'ed deps predate CMake 4; 3.31 matches upstream's build images.
# Retried: a mirrorlist hiccup here otherwise throws away a multi-hour runner slot.
for i in 1 2 3; do dnf install -y cmake && break || sleep 30; done
export ONNX_ML=1
export CMAKE_ARGS="-DONNX_GEN_PB_TYPE_STUBS=ON -DONNX_WERROR=OFF"
"${python_exe}" -m pip install -r /onnxruntime_src/tools/ci_build/github/linux/python/requirements.txt
case "$1" in
build)
# Upstream's flags minus --use_vcpkg* (MS-internal asset cache) and --enable_lto
# (link memory/time on the riscv runner).
"${python_exe}" /onnxruntime_src/tools/ci_build/build.py \
--build_dir /build \
--config Release \
--update \
--build \
--allow_running_as_root \
--skip_submodule_sync \
--use_binskim_compliant_compile_flags \
--build_wheel \
--compile_no_warning_as_error \
--cmake_path /usr/bin/cmake \
--parallel
# setup.py's manylinux allow-list has no riscv64 entry, so it skips auditwheel repair.
auditwheel repair -w /build/dist /build/Release/dist/*.whl
;;
test)
"${python_exe}" -m pip install -r /build/Release/requirements.txt
"${python_exe}" -m pip install --no-index --find-links /build/dist onnxruntime
(cd /tmp && "${python_exe}" -c "
import onnxruntime
from onnxruntime.capi import onnxruntime_pybind11_state as s
print(onnxruntime.__version__, s.__file__)
assert s.__file__.endswith('.so'), s.__file__
print(onnxruntime.get_available_providers())")
# build.py:run_onnxruntime_tests' CPU list; the gtest binaries need upstream's /data/onnx mount.
cd /build/Release
rc=0
for test in onnxruntime_test_python.py \
onnxruntime_test_python_global_threadpool.py \
onnxruntime_test_python_autoep.py \
onnxruntime_test_python_sparse_matmul.py \
onnxruntime_test_python_mlops.py \
onnxruntime_test_python_symlink_data.py \
onnxruntime_test_python_backend.py; do
"${python_exe}" "${test}" || rc=1
done
"${python_exe}" -m unittest discover -s quantization -v || rc=1
"${python_exe}" onnxruntime_test_python_backend_mlops.py || rc=1
"${python_exe}" /onnxruntime_src/onnxruntime/test/onnx/gen_test_models.py --output_dir test_models || rc=1
"${python_exe}" onnxruntime_test_python_compile_api.py || rc=1
./onnx_test_runner test_models || rc=1
"${python_exe}" onnx_backend_test_series.py || rc=1
exit "${rc}"
;;
*)
echo "usage: $0 <build|test>" >&2
exit 1
;;
esac
EOF
- name: Build wheel
run: |
podman run -t \
--log-driver=none \
--network=host \
-v "${PWD}":/onnxruntime_src \
-v "${PWD}/build":/build \
--workdir /onnxruntime_src \
-e PYTHON_TAG="${{ matrix.python }}" \
-e PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ \
--pull=newer \
"${MANYLINUX_RISCV64_IMAGE}" \
bash /onnxruntime_src/riscv64-build-and-test.sh build
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: onnxruntime-${{ env.ONNXRUNTIME_VERSION }}-${{ matrix.python }}-manylinux_riscv64
path: build/dist/*.whl
if-no-files-found: error
- name: Test wheel
run: |
podman run -t \
--log-driver=none \
--network=host \
-v "${PWD}":/onnxruntime_src \
-v "${PWD}/build":/build \
--workdir /onnxruntime_src \
-e PYTHON_TAG="${{ matrix.python }}" \
-e PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ \
"${MANYLINUX_RISCV64_IMAGE}" \
bash /onnxruntime_src/riscv64-build-and-test.sh test
publish:
name: Publish onnxruntime ${{ matrix.version }}
needs: [setup, build_wheels]
if: needs.setup.outputs.versions != '[]'
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
permissions:
contents: write
pull-requests: write
uses: $/.github/workflows/_publish-wheel.yml
secrets:
app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }}
with:
artifact-pattern: onnxruntime-${{ matrix.version }}-*-manylinux_riscv64