Skip to content

[Build] Add a cmake option to link with static nvidia libs #26875

@WilliamTambellini

Description

@WilliamTambellini

Describe the issue

As today

target_link_libraries(${target} PRIVATE CUDA::cublasLt CUDA::cublas CUDNN::cudnn_all cudnn_frontend CUDA::curand CUDA::cufft CUDA::cudart

links dynamically with nvidia libs (cublas, cudnn, curand, cudart, cufft).

On Linux, the static libs are available for all these libs: eg libcublas_static.a, libcudart_static.a, ...

Linking with static nvidia libs seems to work by retouching line 252 such as:

if (${onnxruntime_LINK_WITH_STATIC_NVIDIA_LIBS}) 
 set(SUFFIX "_static")
endif()
target_link_libraries(${target} PRIVATE CUDA::cublasLt${SUFFIX} CUDA::cublas${SUFFIX} CUDA::curand${SUFFIX} CUDA::cufft${SUFFIX} CUDA::cudart${SUFFIX} ....

Would you mind if I add a cmake option ("onnxruntime_LINK_WITH_STATIC_NVIDIA_LIBS") to do so, but keeping the default as today (dynamic linking) ?
Best
WT

Urgency

Not urgent but a must have at least for my company as today.

Target platform

Linux

Build script

Just using the official build.py with an extra CMAKE option.

Error / output

Should output a libonnxruntime.so without any deps with nvidia libs.

Visual Studio Version

No response

GCC / Compiler Version

11

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildbuild issues; typically submitted using template

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions