CUDA: Undefined reference to 'cudaCGGetIntrinsicHandle' despite supposedly sufficient dependencies
On Ubuntu Bionic (on a Travis CI machine), I have a target which depends on CUDA::cudart
and CUDA::cuda_driver
. This target makes a call to cudaCGGetIntrinsicHandle()
... which is left unresolved during linkage. The target has a single .cu
source, which is compiled with -dc
(separable compilation) CUDA version is 10.2.89, CMake is 3.21.0-rc2.
This linking error is kind of elusive. I've encountered it in the past, but without being able to consistently reproduce it. At that link you'll also find a weird solution involving changing the LIBRARIES variable in /etc/nvcc.profile
or the environment. See also discussion here.
Note that this function is defined in cuda_device_runtime_api.h
:
extern __device__ __cudart_builtin__ unsigned long long CUDARTAPI cudaCGGetIntrinsicHandle(enum cudaCGScope scope);