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 support for onnxruntime just on Linux with apt #1387

Merged
merged 1 commit into from
Apr 17, 2023
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
11 changes: 11 additions & 0 deletions cmake/Buildbipedal-locomotion-framework.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ if(APPLE OR WIN32)
list(APPEND bipedal-locomotion-framework_OPTIONAL_CMAKE_ARGS "-DENABLE_YarpRobotLoggerDevice:BOOL=OFF")
endif()

# onnxruntime
# Just on Linux without conda, we download onnxruntime
set(FRAMEWORK_USE_onnxruntime OFF)
if(ROBOTOLOGY_ENABLE_DYNAMICS_FULL_DEPS)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ROBOTOLOGY_CONFIGURING_UNDER_CONDA)
include(Fetchonnxruntimebinaries)
set(FRAMEWORK_USE_onnxruntime ON)
endif()
endif()

ycm_ep_helper(bipedal-locomotion-framework TYPE GIT
STYLE GITHUB
REPOSITORY ami-iit/bipedal-locomotion-framework.git
Expand All @@ -79,6 +89,7 @@ ycm_ep_helper(bipedal-locomotion-framework TYPE GIT
-DFRAMEWORK_USE_casadi:BOOL=${ROBOTOLOGY_ENABLE_DYNAMICS_FULL_DEPS}
-DFRAMEWORK_USE_LieGroupControllers:BOOL=${ROBOTOLOGY_ENABLE_DYNAMICS_FULL_DEPS}
-DFRAMEWORK_USE_tomlplusplus:BOOL=${ROBOTOLOGY_ENABLE_DYNAMICS_FULL_DEPS}
-DFRAMEWORK_USE_onnxruntime:BOOL=${FRAMEWORK_USE_onnxruntime}
-DFRAMEWORK_COMPILE_PYTHON_BINDINGS:BOOL=${ROBOTOLOGY_USES_PYTHON}
${bipedal-locomotion-framework_OPTIONAL_CMAKE_ARGS}
DEPENDS ${bipedal-locomotion-framework_DEPENDS})
Expand Down
37 changes: 37 additions & 0 deletions cmake/Fetchonnxruntimebinaries.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (C) Fondazione Istituto Italiano di Tecnologia

# silence deprecation warnings in newer versions of cmake
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()

if(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(FATAL_ERROR "Fetchonnxruntimebinaries is only supported on Linux, not on ${CMAKE_SYSTEM_NAME}")
endif()

set(onnxruntimebinaries_VERSION "1.14.1")
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(onnxruntimebinaries_ARCH "x64")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(onnxruntimebinaries_ARCH "aarch64")
else()
message(FATAL_ERROR "Fetchonnxruntimebinaries is not supported on architecture ${CMAKE_HOST_SYSTEM_PROCESSOR}")
endif()

set(onnxruntimebinaries_URL "https://github.com/microsoft/onnxruntime/releases/download/v${onnxruntimebinaries_VERSION}/onnxruntime-linux-${onnxruntimebinaries_ARCH}-${onnxruntimebinaries_VERSION}.tgz")

FetchContent_Declare(
onnxruntimebinaries
URL ${onnxruntimebinaries_URL}
)

FetchContent_GetProperties(onnxruntimebinaries)
if(NOT onnxruntimebinaries_POPULATED)
message(STATUS "Downloading onnxruntime binaries.")
FetchContent_Populate(onnxruntimebinaries)
file(GLOB onnxruntimebinaries_HEADERS ${onnxruntimebinaries_SOURCE_DIR}/include/*)
file(COPY ${onnxruntimebinaries_HEADERS} DESTINATION ${YCM_EP_INSTALL_DIR}/include)
file(GLOB onnxruntimebinaries_LIBRARIES ${onnxruntimebinaries_SOURCE_DIR}/lib/*)
file(COPY ${onnxruntimebinaries_LIBRARIES} DESTINATION ${YCM_EP_INSTALL_DIR}/lib)
message(STATUS "Installing onnxruntime binaries in ${YCM_EP_INSTALL_DIR}")
endif()