Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag to build without GPU support on Linux #524

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmake/FetchOnnxruntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ set(CUSTOM_ONNXRUNTIME_HASH
""
CACHE STRING "Hash of a downloaded ONNX Runtime tarball")

set(DISABLE_ONNXRUNTIME_GPU
OFF
CACHE STRING "Disables GPU support of ONNX Runtime (Only valid on Linux)")

set(Onnxruntime_VERSION "1.16.3")

if(CUSTOM_ONNXRUNTIME_URL STREQUAL "")
Expand Down Expand Up @@ -106,6 +110,9 @@ else()
"${onnxruntime_SOURCE_DIR}/lib/libonnxruntime_providers_cuda.so"
"${onnxruntime_SOURCE_DIR}/lib/libonnxruntime_providers_tensorrt.so")
endif()
if(DISABLE_ONNXRUNTIME_GPU)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE DISABLE_ONNXRUNTIME_GPU)
endif()
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ${Onnxruntime_LINK_LIBS})
target_include_directories(${CMAKE_PROJECT_NAME} SYSTEM PUBLIC "${onnxruntime_SOURCE_DIR}/include")
install(FILES ${Onnxruntime_INSTALL_LIBS} DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-plugins/${CMAKE_PROJECT_NAME}")
Expand Down
6 changes: 4 additions & 2 deletions src/ort-utils/ort-session-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#include <coreml_provider_factory.h>
#endif

#if defined(__linux__) && defined(__x86_64__)
#if defined(__linux__) && defined(__x86_64__) && \
!defined(DISABLE_ONNXRUNTIME_GPU)
#include <tensorrt_provider_factory.h>
#endif

Expand Down Expand Up @@ -62,7 +63,8 @@ int createOrtSession(filter_data *tf)
#endif

try {
#if defined(__linux__) && defined(__x86_64__)
#if defined(__linux__) && defined(__x86_64__) && \
!defined(DISABLE_ONNXRUNTIME_GPU)
if (tf->useGPU == USEGPU_TENSORRT) {
Ort::ThrowOnError(
OrtSessionOptionsAppendExecutionProvider_Tensorrt(
Expand Down
Loading