[Fix] Add isolated option for TorchScript SDK backend (#1002)
* add option for TorchScript SDK backend * add doc * formatpull/1008/head
parent
124635ec5f
commit
b602356181
|
@ -2,23 +2,27 @@
|
|||
|
||||
project(mmdeploy_torch_net)
|
||||
|
||||
find_package(Torch REQUIRED)
|
||||
find_package(TorchVision)
|
||||
option(MMDEPLOY_TORCHSCRIPT_SDK_BACKEND "Build TorchScript SDK backend" OFF)
|
||||
|
||||
mmdeploy_add_module(${PROJECT_NAME} torch_net.cpp)
|
||||
if (MMDEPLOY_TORCHSCRIPT_SDK_BACKEND)
|
||||
find_package(Torch REQUIRED)
|
||||
find_package(TorchVision QUIET)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
${TORCH_LIBRARIES})
|
||||
mmdeploy_add_module(${PROJECT_NAME} torch_net.cpp)
|
||||
|
||||
target_link_directories(${PROJECT_NAME} INTERFACE
|
||||
$<BUILD_INTERFACE:${Torch_DIR}/../../../lib>)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
${TORCH_LIBRARIES})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
mmdeploy_torchscript_ops_obj)
|
||||
target_link_directories(${PROJECT_NAME} INTERFACE
|
||||
$<BUILD_INTERFACE:${Torch_DIR}/../../../lib>)
|
||||
|
||||
if (TorchVision_FOUND)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE TorchVision::TorchVision)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE -DMMDEPLOY_USE_TORCHVISION=1)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
mmdeploy_torchscript_ops_obj)
|
||||
|
||||
if (TorchVision_FOUND)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE TorchVision::TorchVision)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE -DMMDEPLOY_USE_TORCHVISION=1)
|
||||
endif ()
|
||||
|
||||
add_library(mmdeploy::torch_net ALIAS ${PROJECT_NAME})
|
||||
endif ()
|
||||
|
||||
add_library(mmdeploy::torch_net ALIAS ${PROJECT_NAME})
|
||||
|
|
|
@ -47,6 +47,14 @@ make -j$(nproc)
|
|||
|
||||
- You could follow the instructions of tutorial [How to convert model](../02-how-to-run/convert_model.md)
|
||||
|
||||
## SDK backend
|
||||
|
||||
TorchScript SDK backend may be built by passing `-DMMDEPLOY_TORCHSCRIPT_SDK_BACKEND=ON` to `cmake`.
|
||||
|
||||
Notice that `libtorch` is sensitive to C++ ABI versions. On platforms defaulted to C++11 ABI (e.g. Ubuntu 16+) one may
|
||||
pass `-DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"` to `cmake` to use pre-C++11 ABI for building. In this case all
|
||||
dependencies with ABI sensitive interfaces (e.g. OpenCV) must be built with pre-C++11 ABI.
|
||||
|
||||
## FAQs
|
||||
|
||||
- Error: `projects/thirdparty/libtorch/share/cmake/Caffe2/Caffe2Config.cmake:96 (message):Your installed Caffe2 version uses cuDNN but I cannot find the cuDNN libraries. Please set the proper cuDNN prefixes and / or install cuDNN.`
|
||||
|
|
|
@ -47,6 +47,14 @@ make -j$(nproc)
|
|||
|
||||
- You could follow the instructions of tutorial [How to convert model](../02-how-to-run/convert_model.md)
|
||||
|
||||
## SDK backend
|
||||
|
||||
TorchScript SDK backend may be built by passing `-DMMDEPLOY_TORCHSCRIPT_SDK_BACKEND=ON` to `cmake`.
|
||||
|
||||
Notice that `libtorch` is sensitive to C++ ABI versions. On platforms defaulted to C++11 ABI (e.g. Ubuntu 16+) one may
|
||||
pass `-DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"` to `cmake` to use pre-C++11 ABI for building. In this case all
|
||||
dependencies with ABI sensitive interfaces (e.g. OpenCV) must be built with pre-C++11 ABI.
|
||||
|
||||
## FAQs
|
||||
|
||||
- Error: `projects/thirdparty/libtorch/share/cmake/Caffe2/Caffe2Config.cmake:96 (message):Your installed Caffe2 version uses cuDNN but I cannot find the cuDNN libraries. Please set the proper cuDNN prefixes and / or install cuDNN.`
|
||||
|
|
Loading…
Reference in New Issue