-
cmake
brew install cmake
-
clang
install Xcode or Command Line Tools
xcode-select --install
Please refer to get_started to install conda.
# install pytorch & mmcv
conda install pytorch==1.9.0 torchvision==0.10.0 -c pytorch
pip install -U openmim
mim install mmengine
mim install "mmcv>=2.0.0rc2"
You can skip this chapter if you are only interested in the model converter.
NAME | INSTALLATION |
---|---|
OpenCV (>=3.0) |
|
Both MMDeploy's model converter and SDK share the same inference engines.
You can select you interested inference engines and do the installation by following the given commands.
This document focus on Core ML. The installation of ONNX Runtime, ncnn and TorchScript is similar to the linux platform, please refer to the document linux-x86_64 for installation.
The TorchScript model is used as the IR in the conversion process of the Core ML model. In order to support the custom operator in some models like detection models in mmdet, libtorch needs to be installed.
NAME | PACKAGE | INSTALLATION |
---|---|---|
Core ML | coremltools |
|
TorchScript | libtorch |
1. Libtorch doesn't provide prebuilt arm library for macOS, so you need to compile it yourself. Please note that the version of libtorch must be consistent with the version of pytorch. 2. Take LibTorch 1.9.0 as an example. You can install it like this:
|
cd /the/root/path/of/MMDeploy
export MMDEPLOY_DIR=$(pwd)
-
Core ML
Core ML uses torchscript as IR, to convert models in some codebases like mmdet, you need to compile torchscript custom operators
-
torchscript custom operators
cd ${MMDEPLOY_DIR} mkdir -p build && cd build cmake -DMMDEPLOY_TARGET_BACKENDS=coreml -DTorch_DIR=${Torch_DIR} .. make -j4 && make install
Please check cmake build option.
# You should use `conda install` to install the grpcio in requirements/runtime.txt
conda install grpcio
cd ${MMDEPLOY_DIR}
mim install -v -e .
Note
- Some dependencies are optional. Simply running
pip install -e .
will only install the minimum runtime requirements. To use optional dependencies, install them manually withpip install -r requirements/optional.txt
or specify desired extras when callingpip
(e.g.pip install -e .[optional]
). Valid keys for the extras field are:all
,tests
,build
,optional
.
The following shows an example of building an SDK using Core ML as the inference engine.
-
cpu + Core ML
cd ${MMDEPLOY_DIR} mkdir -p build && cd build cmake .. \ -DMMDEPLOY_BUILD_SDK=ON \ -DMMDEPLOY_BUILD_EXAMPLES=ON \ -DMMDEPLOY_BUILD_SDK_PYTHON_API=ON \ -DMMDEPLOY_TARGET_DEVICES=cpu \ -DMMDEPLOY_TARGET_BACKENDS=coreml \ -DTorch_DIR=${Torch_DIR} make -j4 && make install