FindCUDAToolkit.cmake finds incompatible version of librt

I am using “owl” in combination with OptiX and cuda to ray cast a scene. Recently, I switched to Ubuntu 21.10 from Ubuntu 20.04 LTS which also means a switch to a different Cuda (11.5.119), gcc (11.2) and Cmake (3.18.4) version. Since then I am not able to build “owl” any more.

It fails with

nvlink fatal : Could not open input file ‘/usr/lib/x86_64-linux-gnu/librt.a’

The librt.a under this specific path seems to be incompatible with nvcc because when only allowing libraries under that path, building with the verbose option says it’s incompatible (among other libraries). However, FindCUDAToolkit.cmake finds this particular version of rt and adds this specific path to the target CUDA::cudart_static_deps which then results in above linker error (because owl links to CUDA::cudart_static). When only compiling with -lrt, everything works fine.

This issue wasn’t present before because the CMake version was below 3.17 and FindCUDAToolkit is present only since 3.17.

Not sure if this is something that can be fixed from the cuda side of things or if I should rather address the CMake people. Maybe someone can shed some light if this version of librt is supposed to be incompatible? As I haven’t found anything about this issue, it doesn’t seem to be common.

2 Likes

I’m facing the same issue, even with cmake 3.14, and with 3.20.2., which leads me to believe that something may be wrong with the librt.a or with how nvcc tries to handle it.
Which kernel version are you using? I recently updated my kernel manually from to 5.14 because of an issue with the suspend of my laptop.

find_package(CUDA 11.0 REQUIRED)
string(REPLACE “/usr/lib/x86_64-linux-gnu/librt.a” “” CUDA_LIBRARIES “${CUDA_LIBRARIES}”)

This will make it compile. I don’t know what happens at runtime though if you use this workaround. In my case I can’t actually run the code on the machine I use for developing anyway because I don’t have a NVIDIA GPU. On the machine/cluster I actually compile+run I don’t encounter this error, fortunately.