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
OpenDAS
dlib
Commits
c5f320e6
Commit
c5f320e6
authored
Oct 17, 2015
by
Davis King
Browse files
Made CMake try to compile a CUDA test project to see if the compiler the user is trying
really supports the version of CUDA we found.
parent
681abe78
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
3 deletions
+43
-3
dlib/CMakeLists.txt
dlib/CMakeLists.txt
+14
-3
dlib/dnn/test_for_cuda/CMakeLists.txt
dlib/dnn/test_for_cuda/CMakeLists.txt
+9
-0
dlib/dnn/test_for_cuda/cuda_test.cu
dlib/dnn/test_for_cuda/cuda_test.cu
+20
-0
No files found.
dlib/CMakeLists.txt
View file @
c5f320e6
...
@@ -433,9 +433,20 @@ if (NOT TARGET dlib)
...
@@ -433,9 +433,20 @@ if (NOT TARGET dlib)
/usr/local/lib
/usr/local/lib
)
)
mark_as_advanced
(
cudnn cudnn_include
)
mark_as_advanced
(
cudnn cudnn_include
)
if
(
cudnn
)
# make sure cuda is really working by doing a test compile
message
(
STATUS
"Building a CUDA test project to see if your compiler is compatible with CUDA..."
)
try_compile
(
cuda_test_compile_worked
${
PROJECT_BINARY_DIR
}
/cuda_test_build
${
PROJECT_SOURCE_DIR
}
/dnn/test_for_cuda cuda_test
)
if
(
NOT cuda_test_compile_worked
)
message
(
STATUS
"*** CUDA was found but your compiler failed to compile a simple CUDA program so dlib isn't going to use CUDA.***"
)
endif
()
endif
()
endif
()
endif
()
if
(
CUDA_FOUND AND cudnn AND cudnn_include AND COMPILER_CAN_DO_CPP_11
)
if
(
CUDA_FOUND AND cudnn AND cudnn_include AND COMPILER_CAN_DO_CPP_11 AND cuda_test_compile_worked
)
message
(
STATUS
"Found cuDNN: "
${
cudnn
}
)
message
(
STATUS
"Found cuDNN: "
${
cudnn
}
)
set
(
source_files
${
source_files
}
set
(
source_files
${
source_files
}
dnn/cuda_dlib.cu
dnn/cuda_dlib.cu
...
@@ -449,10 +460,10 @@ if (NOT TARGET dlib)
...
@@ -449,10 +460,10 @@ if (NOT TARGET dlib)
set
(
DLIB_USE_CUDA OFF CACHE STRING
${
DLIB_USE_BLAS_STR
}
FORCE
)
set
(
DLIB_USE_CUDA OFF CACHE STRING
${
DLIB_USE_BLAS_STR
}
FORCE
)
toggle_preprocessor_switch
(
DLIB_USE_CUDA
)
toggle_preprocessor_switch
(
DLIB_USE_CUDA
)
if
(
NOT cudnn OR NOT cudnn_include
)
if
(
NOT cudnn OR NOT cudnn_include
)
message
(
STATUS
"cuDNN NOT FOUND. DLIB WILL NOT USE CUDA."
)
message
(
STATUS
"
***
cuDNN NOT FOUND. DLIB WILL NOT USE CUDA.
***
"
)
endif
()
endif
()
if
(
NOT COMPILER_CAN_DO_CPP_11
)
if
(
NOT COMPILER_CAN_DO_CPP_11
)
message
(
STATUS
"Dlib CUDA support requires C++11 but your compiler doesn't support it."
)
message
(
STATUS
"
***
Dlib CUDA support requires C++11 but your compiler doesn't support it.
***
"
)
endif
()
endif
()
endif
()
endif
()
endif
()
endif
()
...
...
dlib/dnn/test_for_cuda/CMakeLists.txt
0 → 100644
View file @
c5f320e6
cmake_minimum_required
(
VERSION 2.8.4
)
project
(
cuda_test
)
find_package
(
CUDA 7.0 REQUIRED
)
set
(
CUDA_HOST_COMPILATION_CPP ON
)
list
(
APPEND CUDA_NVCC_FLAGS
"-arch=sm_30;-std=c++11;-D__STRICT_ANSI__"
)
cuda_add_library
(
cuda_test STATIC cuda_test.cu
)
dlib/dnn/test_for_cuda/cuda_test.cu
0 → 100644
View file @
c5f320e6
// Copyright (C) 2015 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#include <cuda_runtime.h>
// ------------------------------------------------------------------------------------
__global__
void
cuda_add_arrays
(
const
float
*
a
,
const
float
*
b
,
float
*
out
,
size_t
n
)
{
out
[
0
]
+=
a
[
0
]
+
b
[
0
];
}
void
add_arrays
()
{
cuda_add_arrays
<<<
512
,
512
>>>
(
0
,
0
,
0
,
0
);
}
// ------------------------------------------------------------------------------------
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