Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6ba1c84

Browse files
[#6529][feat] CMake option to link statically with cublas/curand (#7178)
Close#6529.Signed-off-by: William Tambellini <wtambellini@sdl.com>
1 parent7a62df5 commit6ba1c84

File tree

1 file changed

+40
-7
lines changed

1 file changed

+40
-7
lines changed

‎cpp/CMakeLists.txt‎

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ option(ENABLE_MULTI_DEVICE
4545
option(ENABLE_UCX"Enable building with UCX (Uniform Communication X) support"
4646
ON)
4747
option(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+
4852
option(ENABLE_NVSHMEM"Enable building with NVSHMEM support"OFF)
4953
option(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.
154158
setup_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)
162160
set(CUDA_DRV_LIB CUDA::cuda_driver)
163161
set(CUDA_NVML_LIB CUDA::nvml)
164162
set(CUDA_RT_LIB CUDA::cudart_static)
165163
set(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

168195
if(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)
171199
else()
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)
174203
endif()
175204

205+
find_package(CUDAToolkit 11.2 REQUIRED COMPONENTS${CUDA_TOOLKIT_COMPONENTS})
206+
207+
set(CMAKE_CUDA_RUNTIME_LIBRARYStatic)
208+
176209
resolve_dirs(CUDAToolkit_INCLUDE_DIRS"${CUDAToolkit_INCLUDE_DIRS}")
177210

178211
message(STATUS"CUDA library status:")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp