-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docker infra for Adreno target with CLML support
New docker for Adreno that inherits gpu docker and amends android-sdk. For CLML, we need to specify ADRENO_OPENCL via environment variable. CLML SDK can be downlaoded from Qualcomm Developer Network by following https://developer.qualcomm.com/blog/accelerate-your-models-our-opencl-ml-sdk Adreno device is shared with host, hence networking is enabled for Adreno Docker.
- Loading branch information
1 parent
60cf692
commit 0642d86
Showing
9 changed files
with
196 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
# CI docker GPU env | ||
FROM tlcpack/ci-gpu:20220908-060034-62bdc91b1 | ||
|
||
COPY utils/apt-install-and-clear.sh /usr/local/bin/apt-install-and-clear | ||
|
||
# Android SDK | ||
COPY install/ubuntu_install_androidsdk.sh /install/ubuntu_install_androidsdk.sh | ||
RUN bash /install/ubuntu_install_androidsdk.sh | ||
ENV ANDROID_HOME=/opt/android-sdk-linux | ||
ENV ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/21.3.6528147 | ||
ENV PATH /opt/android-sdk-linux/platform-tools:$PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
set -e | ||
set -u | ||
|
||
output_directory=$(realpath ${PWD}/build-adreno-target) | ||
rm -rf ${output_directory} | ||
|
||
mkdir -p ${output_directory} | ||
cd ${output_directory} | ||
|
||
cp ../cmake/config.cmake . | ||
|
||
echo set\(USE_CLML ON\) >> config.cmake | ||
echo set\(USE_CLML_GRAPH_EXECUTOR "${ADRENO_OPENCL}"\) >> config.cmake | ||
echo set\(USE_RPC ON\) >> config.cmake | ||
echo set\(USE_CPP_RPC ON\) >> config.cmake | ||
echo set\(USE_GRAPH_EXECUTOR ON\) >> config.cmake | ||
echo set\(USE_LIBBACKTRACE AUTO\) >> config.cmake | ||
|
||
echo set\(ANDROID_ABI arm64-v8a\) >> config.cmake | ||
echo set\(ANDROID_PLATFORM android-28\) >> config.cmake | ||
echo set\(MACHINE_NAME aarch64-linux-gnu\) >> config.cmake | ||
|
||
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake" \ | ||
-DANDROID_ABI=arm64-v8a \ | ||
-DANDROID_PLATFORM=android-28 \ | ||
-DCMAKE_SYSTEM_VERSION=1 \ | ||
-DCMAKE_FIND_ROOT_PATH="${ADRENO_OPENCL}" \ | ||
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \ | ||
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ | ||
-DCMAKE_CXX_COMPILER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang++" \ | ||
-DCMAKE_C_COMPILER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang" \ | ||
-DMACHINE_NAME="aarch64-linux-gnu" .. | ||
|
||
make -j$(nproc) tvm_rpc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
set -euxo pipefail | ||
|
||
BUILD_DIR=$1 | ||
mkdir -p "$BUILD_DIR" | ||
cd "$BUILD_DIR" | ||
cp ../cmake/config.cmake . | ||
|
||
echo set\(USE_OPENCL ON\) >> config.cmake | ||
echo set\(USE_CLML ON\) >> config.cmake | ||
echo set\(USE_RPC ON\) >> config.cmake | ||
echo set\(USE_GRAPH_EXECUTOR ON\) >> config.cmake | ||
echo set\(USE_LIBBACKTRACE AUTO\) >> config.cmake | ||
echo set\(USE_LLVM ON\) >> config.cmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
set -euxo pipefail | ||
|
||
export TVM_TEST_TARGETS="opencl" | ||
export TVM_RELAY_OPENCL_TEXTURE_TARGETS="opencl -device=adreno" | ||
|
||
source tests/scripts/setup-pytest-env.sh | ||
export PYTHONPATH=${PYTHONPATH}:${TVM_PATH}/apps/extension/python | ||
export LD_LIBRARY_PATH="build:${LD_LIBRARY_PATH:-}" | ||
export TVM_INTEGRATION_TESTSUITE_NAME=python-integration-adreno | ||
|
||
export TVM_TRACKER_HOST=127.0.0.1 | ||
export TVM_TRACKER_PORT=$(((RANDOM % 100) + 9100)) | ||
export RPC_TARGET="adreno" | ||
export TVM_NDK_CC="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang" | ||
|
||
env PYTHONPATH=python python3 -m tvm.exec.rpc_tracker --host "${TVM_TRACKER_HOST}" --port "${TVM_TRACKER_PORT}" & | ||
TRACKER_PID=$! | ||
sleep 5 # Wait for tracker to bind | ||
|
||
export ANDROID_SERIAL=$1 | ||
|
||
adb shell "mkdir -p /data/local/tmp/tvm_ci" | ||
adb push build-adreno-target/tvm_rpc /data/local/tmp/tvm_ci | ||
adb push build-adreno-target/libtvm_runtime.so /data/local/tmp/tvm_ci | ||
|
||
adb reverse tcp:${TVM_TRACKER_PORT} tcp:${TVM_TRACKER_PORT} | ||
adb forward tcp:5000 tcp:5000 | ||
adb forward tcp:5001 tcp:5001 | ||
adb forward tcp:5002 tcp:5002 | ||
env adb shell "cd /data/local/tmp/tvm_ci; killall -9 tvm_rpc; sleep 2; LD_LIBRARY_PATH=/data/local/tmp/tvm_ci/ ./tvm_rpc server --host=0.0.0.0 --port=5000 --port-end=5010 --tracker=127.0.0.1:${TVM_TRACKER_PORT} --key=android" & | ||
DEVICE_PID=$! | ||
sleep 5 # Wait for the device connections | ||
|
||
# cleanup pycache | ||
find . -type f -path "*.pyc" | xargs rm -f | ||
|
||
# Test TVM | ||
make cython3 | ||
|
||
# OpenCL texture test on Adreno | ||
run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-opencl-texture tests/python/relay/opencl_texture | ||
|
||
kill ${TRACKER_PID} | ||
kill ${DEVICE_PID} |