Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PyTorch] update pytorch build instruction on android #1630

Merged
merged 1 commit into from
May 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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