Skip to content

Forward Compatibility CUDA bug with CMake 3.17+ #110

@cameronrutherford

Description

@cameronrutherford

In HiOp, we link against CUDA in the following fashion:

find_package(CUDAToolkit REQUIRED)

if(HIOP_BUILD_SHARED)
  target_link_libraries(hiop_cuda INTERFACE
    CUDA::cusolver
    CUDA::cusparse
    CUDA::cudart
    CUDA::cublasLt
    )
endif()
if(HIOP_BUILD_STATIC)
  target_link_libraries(hiop_cuda INTERFACE 
    CUDA::cusolver_static
    CUDA::cusparse_static
    CUDA::cudart_static
    CUDA::cublasLt_static
    )
endif()

However, when building [email protected] with [email protected] and [email protected], the camp CMake exported configuration ends up creating the camp target as follows (in campTargets.cmake):

# Create imported target camp
add_library(camp STATIC IMPORTED)

set_target_properties(camp PROPERTIES
  INTERFACE_COMPILE_FEATURES "cxx_std_14"
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "cuda_runtime"
)

Per CMake documentation https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html#module:FindCUDAToolkit, this breaks forward compatibility for including and linking CUDA libraries.

When building and running with this configuration of camp, RAJA and Umpire, I end up getting the following adding to my link line:

.../libumpire.a .../libRAJA.so .../libcamp.a -lcuda_runtime /share/apps/cuda/11.4/lib64/libcudart_static.a /usr/lib64/librt.so

Which generates an ld error:

/usr/bin/ld: cannot find -lcuda_runtime

Simply commenting out the line INTERFACE_LINK_LIBRARIES "cuda_runtime" in campTargets.cmake temporarily resolves the issue, but this should probably be updated for forward compatibility.

@davidbeckingsale @pelesh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions