Commit 9485da18 authored by Davis King's avatar Davis King

Updated dlib to work with the released cuDNN V4.0 and also updated the cmake

scripts so they attempt to verify the version of cuDNN you have installed and
print a useful message if that isn't the case.
parent ffe254db
......@@ -455,39 +455,30 @@ if (NOT TARGET dlib)
# linux).
list(APPEND CUDA_NVCC_FLAGS "-arch=sm_30;-std=c++11;-D__STRICT_ANSI__")
message(STATUS "Looking for cuDNN install...")
# Look for cudnn, we will look in the same place as other CUDA
# libraries and also a few other places as well.
find_path(cudnn_include cudnn.h
HINTS ${CUDA_INCLUDE_DIRS}
PATHS /usr/local/include
)
get_filename_component(cudnn_hint_path ${CUDA_CUBLAS_LIBRARIES} PATH)
find_library(cudnn cudnn
HINTS ${cudnn_hint_path}
PATHS /usr/local/lib64
/usr/local/cuda/lib64
/usr/local/cuda/lib
/usr/local/lib
)
if (cudnn)
message(STATUS "Found cuDNN: " ${cudnn})
endif()
mark_as_advanced(cudnn cudnn_include)
include(dnn/test_for_cudnn/find_cudnn.txt)
if (cudnn AND NOT DEFINED cuda_test_compile_worked)
if (cudnn AND NOT DEFINED cuda_test_compile_worked AND NOT DEFINED cudnn_test_compile_worked)
# 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.***")
message(STATUS "*** CUDA was found but your compiler failed to compile a simple CUDA program so dlib isn't going to use CUDA. ***")
else()
message(STATUS "Checking if you have the right version of cuDNN installed.")
try_compile(cudnn_test_compile_worked ${PROJECT_BINARY_DIR}/cudnn_test_build
${PROJECT_SOURCE_DIR}/dnn/test_for_cudnn cudnn_test)
if (cudnn_test_compile_worked)
message(STATUS "Found cuDNN: " ${cudnn})
else()
message(STATUS "*** Found cuDNN, but it looks like the wrong version so dlib will not use it. ***")
endif()
endif()
endif()
endif()
if (CUDA_FOUND AND cudnn AND cudnn_include AND COMPILER_CAN_DO_CPP_11 AND cuda_test_compile_worked)
if (CUDA_FOUND AND cudnn AND cudnn_include AND COMPILER_CAN_DO_CPP_11 AND cuda_test_compile_worked AND cudnn_test_compile_worked)
set(source_files ${source_files}
dnn/cuda_dlib.cu
dnn/cudnn_dlibapi.cpp
......@@ -504,11 +495,11 @@ if (NOT TARGET dlib)
else()
set(DLIB_USE_CUDA OFF CACHE STRING ${DLIB_USE_BLAS_STR} FORCE )
toggle_preprocessor_switch(DLIB_USE_CUDA)
if (NOT cudnn OR NOT cudnn_include)
message(STATUS "***cuDNN V4.0 OR GREATER NOT FOUND. DLIB WILL NOT USE CUDA.***")
if (NOT cudnn OR NOT cudnn_include OR NOT cudnn_test_compile_worked)
message(STATUS "*** cuDNN V4.0 OR GREATER NOT FOUND. DLIB WILL NOT USE CUDA. ***")
endif()
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()
......
......@@ -431,12 +431,16 @@ namespace dlib
const float in_scale = 1;
const float out_scale = 1;
const float in_scale_params = 1;
const float out_scale_params = 0;
CHECK_CUDNN(cudnnBatchNormalizationBackward(
context(),
CUDNN_BATCHNORM_PER_ACTIVATION,
&in_scale,
&out_scale,
&in_scale_params,
&out_scale_params,
descriptor(src),
src.device(),
descriptor(gradient_input),
......@@ -600,12 +604,16 @@ namespace dlib
const float in_scale = 1;
const float out_scale = 1;
const float in_scale_params = 1;
const float out_scale_params = 0;
CHECK_CUDNN(cudnnBatchNormalizationBackward(
context(),
CUDNN_BATCHNORM_SPATIAL,
&in_scale,
&out_scale,
&in_scale_params,
&out_scale_params,
descriptor(src),
src.device(),
descriptor(gradient_input),
......
cmake_minimum_required(VERSION 2.8.4)
project(cudnn_test)
include(../../use_cpp_11.cmake)
include_directories(${cudnn_include})
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__")
add_definitions(-DDLIB_USE_CUDA)
include(find_cudnn.txt)
cuda_add_library(cudnn_test STATIC ../cudnn_dlibapi.cpp ${cudnn} )
message(STATUS "Looking for cuDNN install...")
# Look for cudnn, we will look in the same place as other CUDA
# libraries and also a few other places as well.
find_path(cudnn_include cudnn.h
HINTS ${CUDA_INCLUDE_DIRS}
PATHS /usr/local/include
)
get_filename_component(cudnn_hint_path ${CUDA_CUBLAS_LIBRARIES} PATH)
find_library(cudnn cudnn
HINTS ${cudnn_hint_path}
PATHS /usr/local/lib64
/usr/local/cuda/lib64
/usr/local/cuda/lib
/usr/local/lib
)
mark_as_advanced(cudnn cudnn_include)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment