All the commands listed in the following chapters are verified on Windows 10.
- Download and install Visual Studio 2019
- Add the path of
cmake
to the environment variablePATH
, i.e., "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin" - Install cuda toolkit if NVIDIA gpu is available. You can refer to the official guide.
NAME | INSTALLATION |
---|---|
conda | Please install conda according to the official guide. After installation, open anaconda powershell prompt under the Start Menu as the administrator, because: 1. All the commands listed in the following text are verified in anaconda powershell 2. As an administrator, you can install the thirdparty libraries to the system path so as to simplify MMDeploy build command Note: if you are familiar with how cmake works, you can also use anaconda powershell prompt as an ordinary user.
|
PyTorch (>=1.8.0) |
Install PyTorch>=1.8.0 by following the official instructions. Be sure the CUDA version PyTorch requires matches that in your host.
|
mmcv-full | Install mmcv-full as follows. Refer to the guide for details.
|
You can skip this chapter if you are only interested in the model converter.
NAME | INSTALLATION |
---|---|
OpenCV (>=3.0) |
1. Find and download OpenCV 3+ for windows from here. 2. You can download the prebuilt package and install it to the target directory. Or you can build OpenCV from its source. 3. Find where OpenCVConfig.cmake locates in the installation directory. And export its path to the environment variable PATH like this,
|
pplcv | A high-performance image processing library of openPPL. It is optional which only be needed if cuda platform is required.
|
Both MMDeploy's model converter and SDK share the same inference engines. You can select your interested inference engines and do the installation by following the given commands.
Currently, MMDeploy only verified ONNXRuntime and TensorRT for windows platform. As for the rest, MMDeploy will support them in the future.
NAME | PACKAGE | INSTALLATION |
---|---|---|
ONNXRuntime | onnxruntime (>=1.8.1) |
1. Install python package
|
TensorRT |
TensorRT |
1. Login NVIDIA and download the TensorRT tar file that matches the CPU architecture and CUDA version you are using from here. Follow the guide to install TensorRT. 2. Here is an example of installing TensorRT 8.2 GA Update 2 for Windows x86_64 and CUDA 11.x that you can refer to. First of all, click here to download CUDA 11.x TensorRT 8.2.3.0 and then install it and other dependency like below:
|
cuDNN |
1. Download cuDNN that matches the CPU architecture, CUDA version and TensorRT version you are using from cuDNN Archive. In the above TensorRT's installation example, it requires cudnn8.2. Thus, you can download CUDA 11.x cuDNN 8.2 2. Extract the zip file and set the environment variables
|
|
PPL.NN | ppl.nn | TODO |
OpenVINO | openvino | TODO |
ncnn | ncnn | TODO |
cd \the\root\path\of\MMDeploy
$env:MMDEPLOY_DIR="$pwd"
If one of inference engines among ONNXRuntime, TensorRT and ncnn is selected, you have to build the corresponding custom ops.
- ONNXRuntime Custom Ops
mkdir build -ErrorAction SilentlyContinue
cd build
cmake .. -G "Visual Studio 16 2019" -A x64 -T v142 -DMMDEPLOY_TARGET_BACKENDS="ort" -DONNXRUNTIME_DIR="$env:ONNXRUNTIME_DIR"
cmake --build . --config Release -- /m
cmake --install . --config Release
- TensorRT Custom Ops
mkdir build -ErrorAction SilentlyContinue
cd build
cmake .. -G "Visual Studio 16 2019" -A x64 -T v142 -DMMDEPLOY_TARGET_BACKENDS="trt" -DTENSORRT_DIR="$env:TENSORRT_DIR" -DCUDNN_DIR="$env:CUDNN_DIR"
cmake --build . --config Release -- /m
cmake --install . --config Release
-
ncnn Custom Ops
TODO
Please check cmake build option.
cd $env:MMDEPLOY_DIR
pip install -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
.
MMDeploy provides two recipes as shown below for building SDK with ONNXRuntime and TensorRT as inference engines respectively. You can also activate other engines after the model.
-
cpu + ONNXRuntime
cd $env:MMDEPLOY_DIR mkdir build -ErrorAction SilentlyContinue cd build cmake .. -G "Visual Studio 16 2019" -A x64 -T v142 ` -DMMDEPLOY_BUILD_SDK=ON ` -DMMDEPLOY_BUILD_EXAMPLES=ON ` -DMMDEPLOY_BUILD_SDK_PYTHON_API=ON ` -DMMDEPLOY_TARGET_DEVICES="cpu" ` -DMMDEPLOY_TARGET_BACKENDS="ort" ` -DONNXRUNTIME_DIR="$env:ONNXRUNTIME_DIR" cmake --build . --config Release -- /m cmake --install . --config Release
-
cuda + TensorRT
cd $env:MMDEPLOY_DIR mkdir build -ErrorAction SilentlyContinue cd build cmake .. -G "Visual Studio 16 2019" -A x64 -T v142 ` -DMMDEPLOY_BUILD_SDK=ON ` -DMMDEPLOY_BUILD_EXAMPLES=ON ` -DMMDEPLOY_BUILD_SDK_PYTHON_API=ON ` -DMMDEPLOY_TARGET_DEVICES="cuda" ` -DMMDEPLOY_TARGET_BACKENDS="trt" ` -Dpplcv_DIR="$env:PPLCV_DIR/pplcv-build/install/lib/cmake/ppl" ` -DTENSORRT_DIR="$env:TENSORRT_DIR" ` -DCUDNN_DIR="$env:CUDNN_DIR" cmake --build . --config Release -- /m cmake --install . --config Release
- Release / Debug libraries can not be mixed. If MMDeploy is built with Release mode, all its dependent thirdparty libraries have to be built in Release mode too and vice versa.