forked from deeplearning4j/deeplearning4j
-
Notifications
You must be signed in to change notification settings - Fork 0
220 lines (204 loc) · 9.09 KB
/
build-deploy-linux-arm64.yml
File metadata and controls
220 lines (204 loc) · 9.09 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
on:
workflow_dispatch:
inputs:
buildThreads:
description: 'Build threads for libnd4j. Used to control memory usage of builds.'
required: true
default: 2
deployToReleaseStaging:
description: 'Whether to deploy to release staging or not.'
required: false
default: 0
releaseVersion:
description: 'Release version target'
required: false
default: 1.0.0-M3
serverId:
description: 'Server id to publish to'
required: false
default: central
snapshotVersion:
description: 'Snapshot version target'
required: false
default: 1.0.0-SNAPSHOT
mvnFlags:
description: "Extra maven flags (must escape input yourself if used)"
required: false
default:
libnd4jUrl:
description: 'Sets a libnd4j download url for this build. LIBND4J_HOME will automatically be set. Should be used when only needing to build other modules.'
required: false
default:
runsOn:
description: 'System to run on'
required: false
default: ubuntu-22.04-arm
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
swapSize:
description: 'Swap file size in GB (e.g., 8 for 8GB)'
required: false
default: 8
jobs:
linux-arm64:
runs-on: ${{ github.event.inputs.runsOn }}
strategy:
fail-fast: false
matrix:
helper: [armcompute, ""]
include:
- mvn_ext: ${{ github.event.inputs.mvnFlags }}
- debug_enabled: ${{ github.event.inputs.debug_enabled }}
- deploy_to_release_staging: ${{ github.event.inputs.deployToReleaseStaging }}
- release_version: ${{ github.event.inputs.releaseVersion }}
- snapshot_version: ${{ github.event.inputs.snapshotVersion }}
- server_id: ${{ github.event.inputs.serverId }}
- build_threads: ${{ github.event.inputs.buildThreads }}
- swap_size: ${{ github.event.inputs.swapSize }}
steps:
- uses: AutoModality/action-clean@v1
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.8.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Configure swap space
shell: bash
run: |
sudo fallocate -l 16G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo sysctl vm.swappiness=60
free -h
- name: Cache protobuf install
uses: actions/cache@v4
id: cache-protobuf
with:
path: /opt/protobuf
key: ${{ runner.os }}-protobuf
- uses: ./.github/actions/install-protobuf-linux
if: steps.cache-protobuf.outputs.cache-hit != 'true'
- name: Set mvn build command based on matrix
shell: bash
run: |
LIBND4J_CLASSIFIER="linux-arm64"
echo "LIBND4J_CLASSIFIER=${LIBND4J_CLASSIFIER}" >> $GITHUB_ENV
echo "OPENBLAS_JAR=openblas-0.3.28-1.5.11-linux-arm64.jar" >> $GITHUB_ENV
echo "ARMCOMPUTE_TARGET=arm64-v8a" >> $GITHUB_ENV
if [ "${{ github.event.inputs.libnd4jUrl }}" != '' ]; then
modules=':nd4j-native,:nd4j-native-preset'
else
modules=':nd4j-native,:nd4j-native-preset,:libnd4j'
fi
command="mvn ${{ matrix.mvn_ext }} -Posx-aarch64-protoc -Dlibnd4j.generate.flatc=ON --no-transfer-progress -pl $modules -Pcpu -Dlibnd4j.buildthreads=${{ github.event.inputs.buildThreads }} -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.count=3 -Possrh -DskipTestResourceEnforcement=true -Dmaven.javadoc.failOnError=false -Djavacpp.platform=${LIBND4J_CLASSIFIER} -Pcpu --also-make --batch-mode deploy -DskipTests"
if [ "${{ matrix.helper }}" != '' ]; then
mvn_ext=" -Dlibnd4j.helper=${{ matrix.helper }} -Djavacpp.platform.extension=-${{ matrix.helper }} -Dlibnd4j.classifier=${LIBND4J_CLASSIFIER}-${{ matrix.helper }}"
else
mvn_ext=""
fi
command="${command} ${mvn_ext}"
echo "COMMAND=${command}" >> $GITHUB_ENV
- name: Set up Java for publishing to OSSRH
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
server-id: ${{ github.event.inputs.serverId }}
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.SONATYPE_GPG_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
cache: 'maven'
- name: Setup Path
shell: bash
run: |
echo "/opt/protobuf/bin" >> $GITHUB_PATH
echo "/opt/cmake/bin" >> $GITHUB_PATH
- name: Setup OpenBLAS and ARM Compute Library
shell: bash
run: |
# Setup OpenBLAS
mkdir -p "${GITHUB_WORKSPACE}/openblas_home"
cd "${GITHUB_WORKSPACE}/openblas_home"
wget https://repo1.maven.org/maven2/org/bytedeco/openblas/0.3.28-1.5.11/${OPENBLAS_JAR}
unzip ${OPENBLAS_JAR}
OPENBLAS_DIR="${GITHUB_WORKSPACE}/openblas_home/org/bytedeco/openblas/linux-arm64"
echo "OPENBLAS_PATH=${OPENBLAS_DIR}" >> "$GITHUB_ENV"
# Ensure the symlink exists for consistency
ln -sf "${OPENBLAS_DIR}/libopenblas.so.0" "${OPENBLAS_DIR}/libopenblas.so"
# Setup ARM Compute Library if selected
if [ "${{ matrix.helper }}" == "armcompute" ]; then
ARMCOMPUTE_HOME="${GITHUB_WORKSPACE}/armcompute_home"
mkdir -p "${ARMCOMPUTE_HOME}"
cd "${ARMCOMPUTE_HOME}"
wget https://github.com/ARM-software/ComputeLibrary/releases/download/v25.04/arm_compute-v25.04-linux-aarch64-cpu-bin.tar.gz
tar -xzf arm_compute-v25.04-linux-aarch64-cpu-bin.tar.gz
# Set ARMCOMPUTE_ROOT to the explicit path of the extracted contents
EXTRACTED_DIR="${ARMCOMPUTE_HOME}/arm_compute-v25.04-linux-aarch64-cpu-bin"
echo "ARMCOMPUTE_ROOT=${EXTRACTED_DIR}" >> "$GITHUB_ENV"
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${EXTRACTED_DIR}/lib/armv8a-neon" >> "$GITHUB_ENV"
fi
- name: Build with Maven
shell: bash
env:
MAVEN_GPG_KEY: ${{ secrets.SONATYPE_GPG_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PERFORM_RELEASE: ${{ github.event.inputs.deployToReleaseStaging }}
RELEASE_VERSION: ${{ github.event.inputs.releaseVersion }}
SNAPSHOT_VERSION: ${{ github.event.inputs.snapshotVersion }}
RELEASE_REPO_ID: ${{ github.event.inputs.releaseRepoId }}
MAVEN_USERNAME: ${{ secrets.CENTRAL_SONATYPE_TOKEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.CENTRAL_SONATYPE_TOKEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.PACKAGES_GPG_PASS }}
MAVEN_OPTS: -Xmx2g
PROTO_EXEC: /opt/protobuf/bin/protoc
run: |
# Pre-build native libraries with CMake if not using a pre-packaged libnd4j
if [ "${{ github.event.inputs.libnd4jUrl }}" == '' ]; then
echo "Starting manual pre-build of libnd4j..."
# Define CMake arguments for building libnd4j
cmake_args="-DOPENBLAS_PATH=${OPENBLAS_PATH}"
# Add armcompute helper flags if enabled
if [ "${{ matrix.helper }}" == "armcompute" ]; then
echo "Enabling armcompute helper for native build."
cmake_args="${cmake_args} -DHELPERS_armcompute=true -DARMCOMPUTE_ROOT=${ARMCOMPUTE_ROOT}"
fi
# Navigate to libnd4j build directory
cd "${GITHUB_WORKSPACE}/libnd4j"
mkdir -p blasbuild/linux-arm64
cd blasbuild/linux-arm64
# Configure with CMake
echo "Configuring with CMake args: ${cmake_args}"
cmake ${cmake_args} ../..
# Build with specified number of threads
echo "Building with make -j${{ github.event.inputs.buildThreads }}"
make -j${{ github.event.inputs.buildThreads }}
cd ${GITHUB_WORKSPACE}
echo "Manual pre-build of libnd4j finished."
fi
# Run the main Maven build
echo "Running Maven command: ${COMMAND}"
if [ "$PERFORM_RELEASE" == 1 ]; then
bash ${GITHUB_WORKSPACE}/release-specified-component.sh "${RELEASE_VERSION}" "${SNAPSHOT_VERSION}" "${RELEASE_REPO_ID}" "${COMMAND}"
else
eval "${COMMAND}"
fi
- name: Cleanup swap
if: always()
shell: bash
run: |
sudo swapoff /swapfile || true
sudo rm -f /swapfile || true