1. 环境搭建:
1.1 python环境
安装pip
#sudo apt install python-pip
#sudo apt install python3-pip
python安装typing
#python3 -m pip install typing
1.2 jdk环境
#sudo apt-get install openjdk-11-jdk
配置:~/.bashrc
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
1.3 ndk环境
下载r21b版本 NDK
https://dl.google.com/android/repository/android-ndk-r21d-windows-x86_64.zip
https://dl.google.com/android/repository/android-ndk-r21d-darwin-x86_64.zip
https://dl.google.com/android/repository/android-ndk-r21d-linux-x86_64.zip
配置:~/.bashrc
export ANDROID_NDK=/home/ubuntu18/workspace/tools/android-ndk-r21b
export NDK_VERSION=21.1.6352462
1.4 sdk环境
地址:
http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
配置:~/.bashrc
export ANDROID_HOME=/home/ubuntu18/workspace/tools/android-sdk-linux
1.5 安装command tools
# create directory for Android command line tools
mkdir -p $ANDROID_HOME/cmdline-tools
cd $ANDROID_HOME/cmdline-tools
# From link above, set ANDROID_CLT equal to the name of Linux's latest SDK tools package release
export ANDROID_CLT=commandlinetools-linux-8512546_latest.zip
# Download Android command line tools and remove the zip file once finished unzipping
curl -O https://dl.google.com/android/repository/${ANDROID_CLT}
unzip $ANDROID_CLT && rm $ANDROID_CLT
# renames the command line tools directory that just was unzipped
mv cmdline-tools tools
1.6 下载PyTorch:
# cd into whatever directory holds your djl directory
export PYTORCH_VERSION=1.11.0
export ANDROID_NDK=${ANDROID_HOME}/ndk/${NDK_VERSION}
# clone PyTorch to local machine
git clone https://github.com/pytorch/pytorch -b "v${PYTORCH_VERSION}" --recursive
cd pytorch
编译Pytorch forAndroid
# need to build all four ABIs
export BUILD_LITE_INTERPRETER=0
./scripts/build_pytorch_android.sh arm64-v8a,armeabi-v7a,x86,x86_64
2.问题:
2.1. 问题1:
方案:
1. sudo apt-get install gsettings-desktop-schemas
2. sudo apt-get install build-essential
问题2
方案:
sudo apt-get install python3-distutils
如果不行
先卸载 sudo apt-get remove python3-distutils
再安装 sudo apt-get install python3-distutils
问题3://
方案:安装typing_extensions
#python3 -m pip install typing_extensions
问题4:
方案:python3 安装 dataclasses
#python3 -m pip install dataclasses
问题5:
编译出现文件缺失
解决方案: