Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
3e9ab53c
Unverified
Commit
3e9ab53c
authored
May 16, 2024
by
Marco Vela
Committed by
GitHub
May 16, 2024
Browse files
[cmake] switch to FindCUDAToolkit (#6457)
parent
e0ac6356
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
23 deletions
+16
-23
CMakeLists.txt
CMakeLists.txt
+16
-23
No files found.
CMakeLists.txt
View file @
3e9ab53c
...
@@ -200,32 +200,28 @@ if(__INTEGRATE_OPENCL)
...
@@ -200,32 +200,28 @@ if(__INTEGRATE_OPENCL)
endif
()
endif
()
if
(
USE_CUDA
)
if
(
USE_CUDA
)
find_package
(
CUDA 11.0 REQUIRED
)
find_package
(
CUDA
Toolkit
11.0 REQUIRED
)
include_directories
(
${
CUDA_INCLUDE_DIRS
}
)
include_directories
(
${
CUDA
Toolkit
_INCLUDE_DIRS
}
)
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-Xcompiler=
${
OpenMP_CXX_FLAGS
}
-Xcompiler=-fPIC -Xcompiler=-Wall"
)
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-Xcompiler=
${
OpenMP_CXX_FLAGS
}
-Xcompiler=-fPIC -Xcompiler=-Wall"
)
# reference for mapping of CUDA toolkit component versions to supported architectures ("compute capabilities"):
# reference for mapping of CUDA toolkit component versions to supported architectures ("compute capabilities"):
# https://en.wikipedia.org/wiki/CUDA#GPUs_supported
# https://en.wikipedia.org/wiki/CUDA#GPUs_supported
set
(
CUDA_ARCHS
"6
.
0"
"6
.
1"
"6
.
2"
"7
.
0"
"7
.
5"
)
set
(
CUDA_ARCHS
"60"
"61"
"62"
"70"
"75"
)
if
(
CUDA_VERSION VERSION_GREATER_EQUAL
"11
.
0"
)
if
(
CUDA_VERSION VERSION_GREATER_EQUAL
"110"
)
list
(
APPEND CUDA_ARCHS
"8
.
0"
)
list
(
APPEND CUDA_ARCHS
"80"
)
endif
()
endif
()
if
(
CUDA_VERSION VERSION_GREATER_EQUAL
"11
.
1"
)
if
(
CUDA_VERSION VERSION_GREATER_EQUAL
"111"
)
list
(
APPEND CUDA_ARCHS
"8
.
6"
)
list
(
APPEND CUDA_ARCHS
"86"
)
endif
()
endif
()
if
(
CUDA_VERSION VERSION_GREATER_EQUAL
"11
.
5"
)
if
(
CUDA_VERSION VERSION_GREATER_EQUAL
"115"
)
list
(
APPEND CUDA_ARCHS
"8
.
7"
)
list
(
APPEND CUDA_ARCHS
"87"
)
endif
()
endif
()
if
(
CUDA_VERSION VERSION_GREATER_EQUAL
"11
.
8"
)
if
(
CUDA_VERSION VERSION_GREATER_EQUAL
"118"
)
list
(
APPEND CUDA_ARCHS
"8
.
9"
)
list
(
APPEND CUDA_ARCHS
"89"
)
list
(
APPEND CUDA_ARCHS
"9
.
0"
)
list
(
APPEND CUDA_ARCHS
"90"
)
endif
()
endif
()
list
(
POP_BACK CUDA_ARCHS CUDA_LAST_SUPPORTED_ARCH
)
list
(
POP_BACK CUDA_ARCHS CUDA_LAST_SUPPORTED_ARCH
)
list
(
APPEND CUDA_ARCHS
"
${
CUDA_LAST_SUPPORTED_ARCH
}
+PTX"
)
list
(
APPEND CUDA_ARCHS
"
${
CUDA_LAST_SUPPORTED_ARCH
}
+PTX"
)
cuda_select_nvcc_arch_flags
(
CUDA_ARCH_FLAGS
${
CUDA_ARCHS
}
)
string
(
REPLACE
";"
" "
CUDA_ARCH_FLAGS
"
${
CUDA_ARCH_FLAGS
}
"
)
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
${
CUDA_ARCH_FLAGS
}
"
)
if
(
USE_DEBUG
)
if
(
USE_DEBUG
)
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-g"
)
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-g"
)
else
()
else
()
...
@@ -262,7 +258,7 @@ if(USE_CUDA)
...
@@ -262,7 +258,7 @@ if(USE_CUDA)
function
(
add_histogram hsize hname hadd hconst hdir
)
function
(
add_histogram hsize hname hadd hconst hdir
)
add_library
(
histo
${
hsize
}${
hname
}
OBJECT src/treelearner/kernels/histogram
${
hsize
}
.cu
)
add_library
(
histo
${
hsize
}${
hname
}
OBJECT src/treelearner/kernels/histogram
${
hsize
}
.cu
)
set_target_properties
(
histo
${
hsize
}${
hname
}
PROPERTIES CUDA_SEPARABLE_COMPILATION ON
)
set_target_properties
(
histo
${
hsize
}${
hname
}
PROPERTIES CUDA_SEPARABLE_COMPILATION ON
)
set_target_properties
(
histo
${
hsize
}${
hname
}
PROPERTIES CUDA_ARCHITECTURES
OFF
)
set_target_properties
(
histo
${
hsize
}${
hname
}
PROPERTIES CUDA_ARCHITECTURES
${
CUDA_ARCHS
}
)
if
(
hadd
)
if
(
hadd
)
list
(
APPEND histograms histo
${
hsize
}${
hname
}
)
list
(
APPEND histograms histo
${
hsize
}${
hname
}
)
set
(
histograms
${
histograms
}
PARENT_SCOPE
)
set
(
histograms
${
histograms
}
PARENT_SCOPE
)
...
@@ -608,13 +604,10 @@ if(__INTEGRATE_OPENCL)
...
@@ -608,13 +604,10 @@ if(__INTEGRATE_OPENCL)
endif
()
endif
()
if
(
USE_CUDA
)
if
(
USE_CUDA
)
# Disable cmake warning about policy CMP0104. Refer to issue #3754 and PR #4268.
set_target_properties
(
lightgbm_objs PROPERTIES CUDA_ARCHITECTURES
${
CUDA_ARCHS
}
)
# Custom target properties does not propagate, thus we need to specify for
set_target_properties
(
_lightgbm PROPERTIES CUDA_ARCHITECTURES
${
CUDA_ARCHS
}
)
# each target that contains or depends on cuda source.
set_target_properties
(
lightgbm_objs PROPERTIES CUDA_ARCHITECTURES OFF
)
set_target_properties
(
_lightgbm PROPERTIES CUDA_ARCHITECTURES OFF
)
if
(
BUILD_CLI
)
if
(
BUILD_CLI
)
set_target_properties
(
lightgbm PROPERTIES CUDA_ARCHITECTURES
OFF
)
set_target_properties
(
lightgbm PROPERTIES CUDA_ARCHITECTURES
${
CUDA_ARCHS
}
)
endif
()
endif
()
set_target_properties
(
lightgbm_objs PROPERTIES CUDA_SEPARABLE_COMPILATION ON
)
set_target_properties
(
lightgbm_objs PROPERTIES CUDA_SEPARABLE_COMPILATION ON
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment