Skip to content

Commit 8f841e6

Browse files
authored
[xgboost] Adds xgboost aarch64 support (deepjavalibrary#2659)
1 parent 1257746 commit 8f841e6

File tree

3 files changed

+97
-1
lines changed

3 files changed

+97
-1
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Native S3 XGBoost
2+
3+
on:
4+
workflow_dispatch:
5+
xgb_version:
6+
description: 'xgboost version'
7+
required: false
8+
9+
jobs:
10+
create-aarch64-runner:
11+
if: github.repository == 'deepjavalibrary/djl'
12+
runs-on: [ self-hosted, scheduler ]
13+
steps:
14+
- name: Create new Graviton instance
15+
id: create_aarch64
16+
run: |
17+
cd /home/ubuntu/djl_benchmark_script/scripts
18+
token=$( curl -X POST -H "Authorization: token ${{ secrets.ACTION_RUNNER_PERSONAL_TOKEN }}" \
19+
https://api.github.com/repos/deepjavalibrary/djl/actions/runners/registration-token \
20+
--fail \
21+
| jq '.token' | tr -d '"' )
22+
./start_instance.sh action_graviton $token djl
23+
outputs:
24+
aarch64_instance_id: ${{ steps.create_aarch64.outputs.action_graviton_instance_id }}
25+
26+
build-xgboost-jni-aarch64:
27+
runs-on: [ self-hosted, aarch64 ]
28+
container: centos:7
29+
timeout-minutes: 30
30+
needs: create-aarch64-runner
31+
steps:
32+
- uses: actions/checkout@v3
33+
- name: Install Environment
34+
run: |
35+
yum -y update
36+
yum -y install centos-release-scl-rh epel-release
37+
yum -y install devtoolset-7 git patch libstdc++-static curl python3-devel
38+
curl -L -o cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v3.27.0-rc2/cmake-3.27.0-rc2-linux-aarch64.tar.gz
39+
tar xvfz cmake.tar.gz
40+
ln -sf $PWD/cmake-3.*/bin/cmake /usr/bin/cmake
41+
cmake --version
42+
pip3 install awscli --upgrade
43+
- name: Set up JDK 11
44+
uses: actions/setup-java@v3
45+
with:
46+
distribution: 'corretto'
47+
java-version: 11
48+
- name: Release JNI prep
49+
run: |
50+
XGBOOST_VERSION=${{ github.event.inputs.xgb_version }}
51+
XGBOOST_VERSION=${XGBOOST_VERSION:-$(cat gradle.properties | awk -F '=' '/xgboost_version/ {print $2}')}
52+
git clone https://github.com/dmlc/xgboost --recursive -b v"$XGBOOST_VERSION"
53+
export PATH=$PATH:/opt/rh/devtoolset-7/root/usr/bin
54+
cd xgboost/jvm-packages
55+
python3 create_jni.py
56+
cd ../..
57+
- name: Configure AWS Credentials
58+
uses: aws-actions/configure-aws-credentials@v1-node16
59+
with:
60+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
61+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
62+
aws-region: us-east-2
63+
- name: Copy files to S3 with the AWS CLI
64+
run: |
65+
XGBOOST_VERSION=${{ github.event.inputs.xgb_version }}
66+
XGBOOST_VERSION=${XGBOOST_VERSION:-$(cat gradle.properties | awk -F '=' '/xgboost_version/ {print $2}')}
67+
aws s3 cp xgboost/lib/libxgboost4j.so s3://djl-ai/publish/xgboost/${XGBOOST_VERSION}/jnilib/linux/aarch64/
68+
aws cloudfront create-invalidation --distribution-id E371VB8JQ6NRVY --paths "/xgboost/${XGBOOST_VERSION}/jnilib*"
69+
70+
stop-runners:
71+
if: ${{ github.repository == 'deepjavalibrary/djl' && always() }}
72+
runs-on: [ self-hosted, scheduler ]
73+
needs: [ create-aarch64-runner, build-xgboost-jni-aarch64 ]
74+
steps:
75+
- name: Stop all instances
76+
run: |
77+
cd /home/ubuntu/djl_benchmark_script/scripts
78+
instance_id=${{ needs.create-aarch64-runner.outputs.aarch64_instance_id }}
79+
./stop_instance.sh $instance_id

engines/ml/xgboost/build.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.util.zip.GZIPInputStream
2+
13
group "ai.djl.ml.xgboost"
24
boolean isGpu = project.hasProperty("gpu")
35
def XGB_FLAVOR = isGpu ? "-gpu" : ""
@@ -34,6 +36,22 @@ dependencies {
3436
}
3537
}
3638

39+
compileJava.dependsOn(processResources)
40+
41+
processResources {
42+
def jnilibDir = "${project.buildDir}/classes/java/main/lib/linux/aarch64/"
43+
outputs.dir file(jnilibDir)
44+
doLast {
45+
def url = "https://publish.djl.ai/xgboost/${xgboost_version}/jnilib/linux/aarch64/libxgboost4j.so"
46+
def file = new File("${jnilibDir}/libxgboost4j.so")
47+
if (!file.exists()) {
48+
project.logger.lifecycle("Downloading ${url}")
49+
def downloadPath = new URL(url)
50+
downloadPath.withInputStream { i -> file.withOutputStream { it << i } }
51+
}
52+
}
53+
}
54+
3755
jar {
3856
from {
3957
(configurations.compileClasspath - configurations.exclusion).collect {

engines/ml/xgboost/src/test/java/ai/djl/ml/xgboost/XgbModelTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public class XgbModelTest {
4242

4343
@BeforeClass
4444
public void downloadXGBoostModel() throws IOException {
45-
TestRequirements.notArm();
4645
TestRequirements.notWindows();
4746

4847
Path modelDir = Paths.get("build/model");

0 commit comments

Comments
 (0)