From 6a07df666b45d1e8dffdaf083d26a831d476e31e Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Sun, 11 Jul 2021 18:12:39 +0100 Subject: [PATCH] RF: Further tweaks to cuda lib linking --- config/buildSettings.mk | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/config/buildSettings.mk b/config/buildSettings.mk index f258b82..4bccbcf 100644 --- a/config/buildSettings.mk +++ b/config/buildSettings.mk @@ -153,15 +153,27 @@ ifneq ($(shell which nvcc), ) # was invoked with "make CUDA_STATIC=1". _CUDALIBS = -lcuda ifdef CUDA_STATIC - # The cuda/cudart libs are handled by nvcc. Other - # components of the CUDA toolkit are provided as - # both dynamic and static libraries. "_CUDALIBS" + # The cuda/cudart/cudadevrt libs are handled by nvcc. + # Other components of the CUDA toolkit are provided + # as both dynamic and static libraries. "_CUDALIBS" # is what is used to construct the final NVCCLDFLAGS - # (see vars.mk) - # Other CUDA toolkit components will be added here - # on an as-needed basis. - NVCCFLAGS += --cudart=static --cudadevrt=static - _CUDALIBS += $(subst -lcublas,-lcublas_static -lcublasLt_static -lculibos, \ + # (see vars.mk). + # + # --cudadevrt was added in CUDA/nvcc 10.* + # + # In CUDA 10.* and newer, cublas_static requires + # cublas_Lt_static, in addition to culibos + ifeq ($(patsubst 9.%,,${CUDA_VER}),) + CUBLAS_STATIC = -lcublas_static -lculibos + NVCCFLAGS += --cudart=static + else + CUBLAS_STATIC = -lcublas_static -lcublasLt_static -lculibos + NVCCFLAGS += --cudart=static --cudadevrt=static + endif + + # Other CUDA toolkit components will + # be added here on an as-needed basis. + _CUDALIBS += $(subst -lcublas,${CUBLAS_STATIC}, \ $(subst -lcurand,-lcurand_static,${CUDALIBS})) else NVCCFLAGS += --cudart=shared --cudadevrt=static -- GitLab