Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
Megvii Engine Team c2e9860feb | 2 years ago | |
---|---|---|
.. | ||
Makefile | 1 year ago | |
README.md | 2 years ago | |
dump_model.py | 1 year ago | |
extern_c_opr.h | 3 years ago | |
mace_loader.cpp | 1 year ago |
load_and_run
for arm64-v8aNOTICE: build depends on NDK
after download, please config env by:
export NDK_ROOT=path/to/ndk
export ANDROID_NDK_HOME=${NDK_ROOT}
export PATH=${NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/:$PATH
cd $MEGENGINE_HOME
git checkout v1.0.0 (we only test v1.0.0 version)
./scripts/cmake-build/cross_build_android_arm_inference.sh -a arm64-v8a -r
After successfully built:
$MEGENGINE_HOME/build_dir/android/arm64-v8a/Release/install/bin
$MEGENGINE_HOME/build_dir/android/arm64-v8a/Release/install/lib
cd $MACE_HOME
RUNTIME=GPU bash tools/cmake/cmake-build-arm64-v8a.sh
export SDKPATH=${MACE_HOME}/build/cmake-build/arm64-v8a/install
After successfully libmace.so should be in $MACE_HOME/build/cmake-build/arm64-v8a/install/lib/libmace.so
If SDKPATH
is not set, by default it's ./arm64-v8a
You can run with debug mode(by adding DEBUG=1
to make command), which will show more running information
python3 dump_model.py --input path/to/resnet_50.pb --param path/to/resnet_50.data --output resnet_50.mdl --config path/to/resnet_50.yml
*.pb
file denotes the model structure, *.data
denotes the model parameters
Check here to learn how to write yml files for MACE
First of all, send all files to the executed device(for example: /data/local/tmp/test/):
As mace build with c++_shared
by default, but old AOSP device do not have libc++_shared.so
by default, if you use this class devices
also need send it to devices, which always can be found at ${NDK_ROOT}/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so
login to device
cd /path/to/ (for example: /data/local/tmp/test/)
MGB_MACE_RUNTIME=GPU MGB_MACE_OPENCL_CACHE_PATH=./ MGB_MACE_LOADER_FORMAT=NCHW LD_LIBRARY_PATH=. ./load_and_run resnet_50.mdl --c-opr-lib libmace_loader.so --input input-bs1.npy
RUNTIME candidates:
MGB_MACE_OPENCL_CACHE_PATH
is the directory path where OpenCL binary cache writes to (the cache file name is always mace_cl_compiled_program.bin
), if the cache file does not exist then it will be created.
We mainly use NCHW data format, if you have NHWC model, use environment MGB_MACE_LOADER_FORMAT=NHWC
For CPU runtime, default running thread is 1, could be specified with MGB_MACE_NR_THREADS=n
if you want to run with HEXAGON runtime, more efforts should be made, please check here.
MACE supports tuning on specific SoC to optimize the performace on GPU, see doc.
To enable this feature, use MGB_MACE_TUNING_PARAM_PATH
env to give the path to the tuning param file.
To generate the tunig param file, give MACE_TUNING=1
env and set the MACE_RUN_PARAMETER_PATH
to the file name you want.
# search for tuning param
MACE_TUNING=1 MACE_RUN_PARAMETER_PATH=opencl/vgg16.tune_param MGB_MACE_RUNTIME=GPU MGB_MACE_OPENCL_PATH=opencl MGB_MACE_LOADER_FORMAT=NCHW ./load_and_run mace/vgg16.mdl --c-opr-lib libmace_loader.so --input 4d.npy
# then run test using the param
MGB_MACE_TUNING_PARAM_PATH=opencl/vgg16.tune_param MGB_MACE_RUNTIME=GPU MGB_MACE_OPENCL_PATH=opencl MGB_MACE_LOADER_FORMAT=NCHW ./load_and_run mace/vgg16.mdl --c-opr-lib libmace_loader.so --input 4d.npy
天元(MegEngine)是旷视自主研发的开源深度学习框架,于2020年3月正式在 OpenI 启智社区开源,天元能够帮助开发者高效的完成深度学习算法的设计、训练、部署,有效提升AI研发工作效率。
C++ Cuda Python C Starlark other
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》