Skip to content

Commit

Permalink
update pytorch build instruction on android
Browse files Browse the repository at this point in the history
  • Loading branch information
Qing Lan committed May 7, 2022
1 parent 46d3479 commit e55bca4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/native_s3_pytorch_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@ jobs:
matrix:
format: ["armeabi-v7a", "arm64-v8a", "x86" ,"x86_64"]
env:
PYTORCH_VERSION: "1.8.1"
NDK_VERSION: "20.0.5594570"
PYTORCH_VERSION: "1.11.0"
NDK_VERSION: "21.0.6113669"
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Set up Python3
uses: actions/setup-python@v1
with:
python-version: '3.x'
uses: actions/setup-python@v3
- name: clone pytorch
run: |
git clone https://github.com/pytorch/pytorch android_pytorch_tmp -b "v${PYTORCH_VERSION}" --recursive
Expand All @@ -34,7 +32,7 @@ jobs:
export ANDROID_NDK=${ANDROID_SDK_ROOT}/ndk/${NDK_VERSION}
export ANDROID_ABI=${{ matrix.format }}
cd android_pytorch_tmp
bash ./scripts/build_android.sh
BUILD_LITE_INTERPRETER=0 ./scripts/build_android.sh
cd build_android
zip -r ${{ matrix.format }}_native.zip install/include lib
- name: Configure AWS Credentials
Expand Down
5 changes: 4 additions & 1 deletion engines/pytorch/pytorch-native/build_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ if [[ ! -d libtorch_android/"$FLAVOR" ]]; then
fi
fi

if [[ "$VERSION" =~ ^1\.10\..*|^1\.9\..* ]]; then
PT_OLD_VERSION=1
fi
pushd .

rm -rf build
mkdir build && cd build
mkdir classes
javac -sourcepath ../../pytorch-engine/src/main/java/ ../../pytorch-engine/src/main/java/ai/djl/pytorch/jni/PyTorchLibrary.java -h include -d classes
cmake -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK"/build/cmake/android.toolchain.cmake -DANDROID_ABI="$FLAVOR" -DANDROID_NATIVE_API_LEVEL=21 -DBUILD_ANDROID=ON ..
cmake -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK"/build/cmake/android.toolchain.cmake -DANDROID_ABI="$FLAVOR" -DANDROID_NATIVE_API_LEVEL=21 -DBUILD_ANDROID=ON -DPT_OLD_VERSION=${PT_OLD_VERSION} ..
cmake --build . --config Release -- -j "${NUM_PROC}"
popd

0 comments on commit e55bca4

Please sign in to comment.