Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
E
elsa
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
33
Issues
33
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
9
Merge Requests
9
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
External Wiki
External Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
IP
elsa
Commits
6ad66e61
Commit
6ad66e61
authored
Feb 12, 2020
by
Jens Petit
Committed by
Tobias Lasser
Feb 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CUDA compute capability detection stand-alone
parent
fa4ecd06
Pipeline
#216659
passed with stages
in 41 minutes and 38 seconds
Changes
2
Pipelines
10
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
57 deletions
+60
-57
cmake/ComputeCapabilityCUDA.cmake
cmake/ComputeCapabilityCUDA.cmake
+59
-0
elsa/projectors_cuda/projector_kernels/CMakeLists.txt
elsa/projectors_cuda/projector_kernels/CMakeLists.txt
+1
-57
No files found.
cmake/ComputeCapabilityCUDA.cmake
0 → 100644
View file @
6ad66e61
cmake_minimum_required
(
VERSION 3.10
)
################################################################################################
# Automatic GPU detection is not included with every CMake release (e.g. it is unavailable in
# the CMake version installed with the default Ubuntu package manager)
#
# Taken from the official CMake repository, with minor modifications:
# https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/FindCUDA/select_compute_arch.cmake
#
# A function for automatic detection of GPUs installed (if autodetection is enabled)
# Usage:
# CUDA_DETECT_INSTALLED_GPUS(OUT_VARIABLE)
#
function
(
CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE
)
set
(
file
"
${
PROJECT_BINARY_DIR
}
/detect_cuda_compute_capabilities.cu"
)
file
(
WRITE
${
file
}
""
"#include <cuda_runtime.h>
\n
"
"#include <cstdio>
\n
"
"int main()
\n
"
"{
\n
"
" int count = 0;
\n
"
" if (cudaSuccess != cudaGetDeviceCount(&count)) return -1;
\n
"
" if (count == 0) return -1;
\n
"
" for (int device = 0; device < count; ++device)
\n
"
" {
\n
"
" cudaDeviceProp prop;
\n
"
" if (cudaSuccess == cudaGetDeviceProperties(&prop, device))
\n
"
" std::printf(
\"
%d.%d
\"
, prop.major, prop.minor);
\n
"
" }
\n
"
" return 0;
\n
"
"}
\n
"
)
try_run
(
run_result compile_result
${
PROJECT_BINARY_DIR
}
${
file
}
RUN_OUTPUT_VARIABLE compute_capabilities
)
# Filter unrelated content out of the output.
string
(
REGEX MATCHALL
"[0-9]+
\\
.[0-9]+"
compute_capabilities
"
${
compute_capabilities
}
"
)
if
(
run_result EQUAL 0
)
string
(
REPLACE
"2.1"
"2.1(2.0)"
compute_capabilities
"
${
compute_capabilities
}
"
)
set
(
CUDA_GPU_DETECT_OUTPUT
${
compute_capabilities
}
CACHE INTERNAL
"Returned GPU architectures from detect_gpus tool"
FORCE
)
endif
()
if
(
NOT CUDA_GPU_DETECT_OUTPUT
)
message
(
WARNING
"Automatic GPU detection failed. Defaulting to 3.0. You can also set CUDA_ARCH_TYPES manually."
)
set
(
${
OUT_VARIABLE
}
"3.0"
PARENT_SCOPE
)
separate_arguments
(
OUT_VARIABLE
)
else
()
# Filter based on CUDA version supported archs
message
(
STATUS
"Automatically detected GPU architectures:
${
CUDA_GPU_DETECT_OUTPUT
}
"
)
separate_arguments
(
CUDA_GPU_DETECT_OUTPUT
)
set
(
${
OUT_VARIABLE
}
${
CUDA_GPU_DETECT_OUTPUT
}
PARENT_SCOPE
)
endif
()
list
(
REMOVE_DUPLICATES OUT_VARIABLE
)
list
(
SORT OUT_VARIABLE
)
endfunction
()
elsa/projectors_cuda/projector_kernels/CMakeLists.txt
View file @
6ad66e61
cmake_minimum_required
(
VERSION 3.10
)
################################################################################################
# Automatic GPU detection is not included with every CMake release (e.g. it is unavailable in
# the CMake version installed with the default Ubuntu package manager)
#
# Taken from the official CMake repository, with minor modifications:
# https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/FindCUDA/select_compute_arch.cmake
#
# A function for automatic detection of GPUs installed (if autodetection is enabled)
# Usage:
# CUDA_DETECT_INSTALLED_GPUS(OUT_VARIABLE)
#
function
(
CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE
)
set
(
file
"
${
PROJECT_BINARY_DIR
}
/detect_cuda_compute_capabilities.cu"
)
file
(
WRITE
${
file
}
""
"#include <cuda_runtime.h>
\n
"
"#include <cstdio>
\n
"
"int main()
\n
"
"{
\n
"
" int count = 0;
\n
"
" if (cudaSuccess != cudaGetDeviceCount(&count)) return -1;
\n
"
" if (count == 0) return -1;
\n
"
" for (int device = 0; device < count; ++device)
\n
"
" {
\n
"
" cudaDeviceProp prop;
\n
"
" if (cudaSuccess == cudaGetDeviceProperties(&prop, device))
\n
"
" std::printf(
\"
%d.%d
\"
, prop.major, prop.minor);
\n
"
" }
\n
"
" return 0;
\n
"
"}
\n
"
)
try_run
(
run_result compile_result
${
PROJECT_BINARY_DIR
}
${
file
}
RUN_OUTPUT_VARIABLE compute_capabilities
)
# Filter unrelated content out of the output.
string
(
REGEX MATCHALL
"[0-9]+
\\
.[0-9]+"
compute_capabilities
"
${
compute_capabilities
}
"
)
if
(
run_result EQUAL 0
)
string
(
REPLACE
"2.1"
"2.1(2.0)"
compute_capabilities
"
${
compute_capabilities
}
"
)
set
(
CUDA_GPU_DETECT_OUTPUT
${
compute_capabilities
}
CACHE INTERNAL
"Returned GPU architectures from detect_gpus tool"
FORCE
)
endif
()
if
(
NOT CUDA_GPU_DETECT_OUTPUT
)
message
(
WARNING
"Automatic GPU detection failed. Defaulting to 3.0. You can also set CUDA_ARCH_TYPES manually."
)
set
(
${
OUT_VARIABLE
}
"3.0"
PARENT_SCOPE
)
separate_arguments
(
OUT_VARIABLE
)
else
()
# Filter based on CUDA version supported archs
message
(
STATUS
"Automatically detected GPU architectures:
${
CUDA_GPU_DETECT_OUTPUT
}
"
)
separate_arguments
(
CUDA_GPU_DETECT_OUTPUT
)
set
(
${
OUT_VARIABLE
}
${
CUDA_GPU_DETECT_OUTPUT
}
PARENT_SCOPE
)
endif
()
list
(
REMOVE_DUPLICATES OUT_VARIABLE
)
list
(
SORT OUT_VARIABLE
)
endfunction
()
include
(
ComputeCapabilityCUDA
)
# make sure host compiler used by NVCC is the one used for the rest of the project
set
(
CMAKE_CUDA_HOST_COMPILER
"
${
CMAKE_CXX_COMPILER
}
"
)
...
...
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