triton-inference-server / server

The Triton Inference Server provides an optimized cloud and edge inferencing solution.
https://docs.nvidia.com/deeplearning/triton-inference-server/user-guide/docs/index.html
BSD 3-Clause "New" or "Revised" License
8.07k stars 1.45k forks source link

Add CMake FetchContent support to triton client libraries #6759

Open philipp-schmidt opened 8 months ago

philipp-schmidt commented 8 months ago

Is there a way to include tritonclient libraries in a CMake project via FetchContent? The following does not work properly.

include(FetchContent)
FetchContent_Declare(TritonClient
    GIT_REPOSITORY https://github.com/triton-inference-server/client
    GIT_TAG main
)
FetchContent_MakeAvailable(TritonClient)

# ...

target_link_libraries(test PRIVATE TritonClient::grpcclient rt m dl)

Including tritonclient via find_package will yield the target TritonClient::grpcclient, but via FetchContent the targets are not available.

Tabrizian commented 8 months ago

@debermudez @matthewkotila @tgerdesnv Is this something that we could potentially add for the C++ clients?

debermudez commented 8 months ago

@Tabrizian Wouldnt this change need to go into the server repo?

philipp-schmidt commented 8 months ago

I have more info to share. The above code snippet misses setting the build flags for TritonClient to e.g. enable the grpc build. Doing so (via SET(...)) will give a target TritonClient::grpcclient, but it will fail to "transitively" find the target GRPC::xxx defined by triton. Tritonclient builds grpc itself so it should be available.

I can post more detailled info in a few days.

debermudez commented 8 months ago

@philipp-schmidt if you have the capacity, you can make a PR and fill out the CLA. We can test locally and verify it.

Tabrizian commented 8 months ago

@Tabrizian Wouldnt this change need to go into the server repo?

No, I think what @philipp-schmidt is proposing is to make changes to the client repo cmakes so that it works with FetchContent semantics.

philipp-schmidt commented 8 months ago
FetchContent_Declare(
    tritonclient
    GIT_REPOSITORY https://github.com/triton-inference-server/client
    GIT_TAG r23.05
)
set(TRITON_ENABLE_CC_GRPC ON)
FetchContent_MakeAvailable(tritonclient)

# ...

target_link_libraries(test PRIVATE TritonClient::grpcclient rt m dl)

This will actually pull the repo and start building stuff, but the output is still:

CMake Error at CMakeLists.txt:70 (target_link_libraries):
  Target "test" links to:

    TritonClient::grpcclient

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.