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

[Build] linking against header-only library cudnn_frontend #22855

Open
ConnorBaker opened this issue Nov 15, 2024 · 2 comments
Open

[Build] linking against header-only library cudnn_frontend #22855

ConnorBaker opened this issue Nov 15, 2024 · 2 comments
Labels
build build issues; typically submitted using template

Comments

@ConnorBaker
Copy link

Describe the issue

I'm packaging onnxruntime for the Nixpkgs CUDA ecosystem (https://github.com/connorbaker/cuda-packages).

When building with nix, I ran into errors while linking because the linker was unable to find -lcudnn_frontend.

My understanding was that cudnn-frontend was a header-only library (https://github.com/NVIDIA/cudnn-frontend) -- why does onnxruntime try to link against a library?

target_link_libraries(${_UT_TARGET} PRIVATE CUDA::cudart cudnn_frontend)

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

Urgency

No response

Target platform

x86_64-linux with TensorRT

Build script

nix build -L --builders '' --no-link github:connorbaker/cuda-packages/fabe15378f8cf5a0870d6189115170a042a802f5#pkgsCuda.sm_89.cudaPackages_12.onnxruntime

Error / output

cuda12.6-onnxruntime> /nix/store/va7kw1i822h95im4jacci19v0cqajfyf-binutils-2.43.1/bin/ld: cannot find -lcudnn_frontend: No such file or directory
cuda12.6-onnxruntime> collect2: error: ld returned 1 exit status
cuda12.6-onnxruntime> ninja: build stopped: subcommand failed.

Visual Studio Version

No response

GCC / Compiler Version

13.3.0

@ConnorBaker ConnorBaker added the build build issues; typically submitted using template label Nov 15, 2024
@tianleiwu
Copy link
Contributor

tianleiwu commented Nov 15, 2024

cudnn_frontend is an interface library. Need use target_link_libraries() in CMake. Interface libraries in CMake are special in that they do not generate any compiled output themselves but propagate build properties, such as include directories or other linked libraries, to targets that depend on them.

Example to use it:

include(cudnn_frontend) # also defines CUDNN::*
if (onnxruntime_USE_CUDA_NHWC_OPS)
if(CUDNN_MAJOR_VERSION GREATER 8)
add_compile_definitions(ENABLE_CUDA_NHWC_OPS)
else()
message( WARNING "To compile with NHWC ops enabled please compile against cuDNN 9 or newer." )
endif()
endif()
target_link_libraries(${target} PRIVATE CUDA::cublasLt CUDA::cublas CUDNN::cudnn_all cudnn_frontend CUDA::curand CUDA::cufft CUDA::cudart
${ABSEIL_LIBS} ${ONNXRUNTIME_PROVIDERS_SHARED} Boost::mp11 safeint_interface)
endif()

Here is related doc about build: https://onnxruntime.ai/docs/build/eps.html#cuda

@snnn
Copy link
Member

snnn commented Nov 15, 2024

cudnn_frontend is a cmake target. It's ok to do so, because the target_link_libraries command will add extra compile flags for the target. In this case, for example, CUDNN_FRONTEND_SKIP_JSON_LIB. But, we may also change it to onnxruntime_add_include_to_target.

onnxruntime_add_include_to_target(${target} cudnn_frontend)

Let me know if it would solve the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build issues; typically submitted using template
Projects
None yet
Development

No branches or pull requests

3 participants