@@ -45,6 +45,10 @@ option(ENABLE_MULTI_DEVICE
4545option (ENABLE_UCX"Enable building with UCX (Uniform Communication X) support"
4646ON )
4747option (NVRTC_DYNAMIC_LINKING"Link against the dynamic NVRTC libraries" OFF )
48+ option (CUBLAS_DYNAMIC_LINKING
49+ "Link against the dynamic cublas/cublasLt libraries" ON )
50+ option (CURAND_DYNAMIC_LINKING"Link against the dynamic curand library" ON )
51+
4852option (ENABLE_NVSHMEM"Enable building with NVSHMEM support" OFF )
4953option (USING_OSS_CUTLASS_LOW_LATENCY_GEMM
5054"Using open sourced Cutlass low latency gemm kernel" ON )
@@ -153,26 +157,55 @@ enable_language(C CXX CUDA)
153157# after that CMake handles it just fine.
154158setup_cuda_architectures()
155159
156- find_package (CUDAToolkit 11.2 REQUIRED COMPONENTS cudart_static cuda_driver
157- cublas cublasLt curand nvml)
158-
159- set (CUBLAS_LIB CUDA::cublas)
160- set (CUBLASLT_LIB CUDA::cublasLt)
161- set (CURAND_LIB CUDA::curand)
162160set (CUDA_DRV_LIB CUDA::cuda_driver)
163161set (CUDA_NVML_LIB CUDA::nvml)
164162set (CUDA_RT_LIB CUDA::cudart_static)
165163set (NVPTX_LIB CUDA::nvptxcompiler_static)
166- set (CMAKE_CUDA_RUNTIME_LIBRARYStatic )
164+
165+ set (CUDA_TOOLKIT_COMPONENTS cudart_static cuda_driver nvml nvptxcompiler_static)
166+
167+ if (CUBLAS_DYNAMIC_LINKING)
168+ set (CUBLAS_LIB CUDA::cublas)
169+ set (CUBLASLT_LIB CUDA::cublasLt)
170+ list (APPEND CUDA_TOOLKIT_COMPONENTS cublas cublasLt)
171+ else ()
172+ if (WIN32 )
173+ message (FATAL_ERROR"Static cublas not available on windows" )
174+ endif ()
175+ message (DEBUG"Linking with static cublas libs" )
176+
177+ set (CUBLAS_LIB CUDA::cublas_static)
178+ set (CUBLASLT_LIB CUDA::cublasLt_static)
179+ list (APPEND CUDA_TOOLKIT_COMPONENTS cublas_static cublasLt_static)
180+ endif ()
181+
182+ if (CURAND_DYNAMIC_LINKING)
183+ set (CURAND_LIB CUDA::curand)
184+ list (APPEND CUDA_TOOLKIT_COMPONENTS curand)
185+ else ()
186+ if (WIN32 )
187+ message (FATAL_ERROR"Static curand not available on windows" )
188+ endif ()
189+ message (DEBUG"Linking with static curand lib" )
190+
191+ set (CURAND_LIB CUDA::curand_static)
192+ list (APPEND CUDA_TOOLKIT_COMPONENTS curand_static)
193+ endif ()
167194
168195if (NVRTC_DYNAMIC_LINKING)
169196 set (NVRTC_LIB CUDA::nvrtc)
170197 set (NVRTC_BUILTINS_LIB CUDA::nvrtc_builtins)
198+ list (APPEND CUDA_TOOLKIT_COMPONENTS nvrtc nvrtc_builtins)
171199else ()
172200 set (NVRTC_LIB CUDA::nvrtc_static)
173201 set (NVRTC_BUILTINS_LIB CUDA::nvrtc_builtins_static)
202+ list (APPEND CUDA_TOOLKIT_COMPONENTS nvrtc_static nvrtc_builtins_static)
174203endif ()
175204
205+ find_package (CUDAToolkit 11.2 REQUIRED COMPONENTS${CUDA_TOOLKIT_COMPONENTS} )
206+
207+ set (CMAKE_CUDA_RUNTIME_LIBRARYStatic )
208+
176209resolve_dirs(CUDAToolkit_INCLUDE_DIRS"${CUDAToolkit_INCLUDE_DIRS} " )
177210
178211message (STATUS "CUDA library status:" )