Skip to content

Commit

Permalink
[cudnn] remove hardcoded version in cmake module (AlexeyAB#3738)
Browse files Browse the repository at this point in the history
collateral fixes: 
* handle opencv4 upgrade on vcpkg
* add yasm (ffmpeg prerequisite) on travis
* install ffmpeg separately from opencv to circumvent time limits
* build only release to halve ci time
* do not build as shared libs when using vcpkg, since default triplets are static
* remove debug configs from appveyor matrix
  • Loading branch information
cenit authored Aug 24, 2019
1 parent 4c315ea commit 35346d2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 46 deletions.
30 changes: 19 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ matrix:
name: macOS - clang - vcpkg
osx_image: xcode10.1
env:
- additional_defines=""
- MATRIX_EVAL="brew install gcc && unset CC && unset CXX"
- additional_defines="-DBUILD_SHARED_LIBS=OFF"
- MATRIX_EVAL="brew install gcc && brew install yasm && unset CC && unset CXX"
- USE_VCPKG=true
- VCPKG_DEFINES="-DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake"

Expand Down Expand Up @@ -111,8 +111,13 @@ matrix:
compiler: gcc
dist: bionic
name: ubuntu 18.04 - gcc - vcpkg
addons:
apt:
update: true
packages:
- yasm
env:
- additional_defines=""
- additional_defines="-DBUILD_SHARED_LIBS=OFF"
- USE_VCPKG=true
- VCPKG_DEFINES="-DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake"
- MATRIX_EVAL=""
Expand Down Expand Up @@ -181,8 +186,13 @@ matrix:
compiler: gcc
dist: bionic
name: ubuntu 18.04 - gcc - CUDA 10 - vcpkg
addons:
apt:
update: true
packages:
- yasm
env:
- additional_defines=""
- additional_defines="-DBUILD_SHARED_LIBS=OFF"
- USE_VCPKG=true
- VCPKG_DEFINES="-DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake"
- CUDACXX=/usr/local/cuda-10.0/bin/nvcc
Expand All @@ -209,22 +219,20 @@ install:
- cd vcpkg
- git pull
- if [ "${USE_VCPKG}" = true ] ; then ./bootstrap-vcpkg.sh ; fi
- if [ "${USE_VCPKG}" = true ] ; then travis_wait ./vcpkg install stb pthreads ; fi
- if [ "${USE_VCPKG}" = true ] ; then echo "set(VCPKG_BUILD_TYPE release)" >> triplets/x64-osx.cmake ; fi
- if [ "${USE_VCPKG}" = true ] ; then echo "set(VCPKG_BUILD_TYPE release)" >> triplets/x64-linux.cmake ; fi
- if [ "${USE_VCPKG}" = true ] ; then travis_wait ./vcpkg install stb pthreads --recurse; fi
- if [ "${USE_VCPKG}" = true ] ; then travis_wait 45 ./vcpkg install ffmpeg --recurse; fi
#- if [ "${USE_VCPKG}" = true ] && [[ ! -z "${CUDACXX}" ]] ; then travis_wait 45 ./vcpkg install opencv[ffmpeg,cuda] --recurse; fi
#- if [ "${USE_VCPKG}" = true ] && [[ -z "${CUDACXX}" ]] ; then travis_wait 45 ./vcpkg install opencv[ffmpeg] --recurse; fi
- if [ "${USE_VCPKG}" = true ] ; then travis_wait 45 ./vcpkg install opencv[ffmpeg] ; fi
- if [ "${USE_VCPKG}" = true ] ; then travis_wait 45 ./vcpkg install opencv[ffmpeg] --recurse; fi
- popd

before_script:
- mkdir build_debug
- cd build_debug
- cmake .. -DCMAKE_BUILD_TYPE="Debug" ${VCPKG_DEFINES} ${additional_defines}
- cd ..
- mkdir build_release
- cd build_release
- cmake .. -DCMAKE_BUILD_TYPE="Release" ${VCPKG_DEFINES} ${additional_defines}
- cd ..

script:
- cd build_debug && cmake --build . --target install -- -j8 && cd ..
- cd build_release && cmake --build . --target install -- -j8 && cd ..
30 changes: 9 additions & 21 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,17 @@ environment:
CYGWIN_NOWINPATH: yes
CYGSH: C:\cygwin64\bin\bash -c
- platform: Win64
COMPILER: vs
configuration: Release
VCPKG_ROOT: C:\Tools\vcpkg
VCPKG_DEFAULT_TRIPLET: x64-windows
USE_CUDA: yes
- platform: Win64
COMPILER: vs
configuration: Debug
VCPKG_ROOT: C:\Tools\vcpkg
VCPKG_DEFAULT_TRIPLET: x64-windows
USE_CUDA: yes
- platform: Win64
COMPILER: vs
configuration: Release
VCPKG_ROOT: C:\Tools\vcpkg
VCPKG_DEFAULT_TRIPLET: x64-windows
USE_CUDA: no
- platform: Win64
USE_CUDA: no
COMPILER: vs
configuration: Debug
configuration: Release
VCPKG_ROOT: C:\Tools\vcpkg
VCPKG_DEFAULT_TRIPLET: x64-windows
USE_CUDA: no
- platform: Win64
COMPILER: vs
configuration: Release
Expand Down Expand Up @@ -71,14 +59,15 @@ install:
- if [%COMPILER%]==[vs] if NOT [%USE_INTEGRATED_LIBS%]==[yes] cd %VCPKG_ROOT%
- if [%COMPILER%]==[vs] if NOT [%USE_INTEGRATED_LIBS%]==[yes] git pull
- if [%COMPILER%]==[vs] if NOT [%USE_INTEGRATED_LIBS%]==[yes] .\bootstrap-vcpkg.bat
- if [%COMPILER%]==[vs] if NOT [%USE_INTEGRATED_LIBS%]==[yes] if [%USE_CUDA%]==[yes] vcpkg install cuda
- if [%COMPILER%]==[vs] if NOT [%USE_INTEGRATED_LIBS%]==[yes] vcpkg install stb pthreads
- if [%COMPILER%]==[vs] if NOT [%USE_INTEGRATED_LIBS%]==[yes] vcpkg install opencv[ffmpeg] ## opencv[ffmpeg,cuda] is too big to build, timing out (>1h). We use plain openCV also for CUDA builds (toolchain can manage this strange situation anyway)
- if [%COMPILER%]==[vs] if NOT [%USE_INTEGRATED_LIBS%]==[yes] echo set(VCPKG_BUILD_TYPE release) >> triplets\%VCPKG_DEFAULT_TRIPLET%.cmake
- if [%COMPILER%]==[vs] if NOT [%USE_INTEGRATED_LIBS%]==[yes] if [%USE_CUDA%]==[yes] vcpkg install cuda --recurse
- if [%COMPILER%]==[vs] if NOT [%USE_INTEGRATED_LIBS%]==[yes] vcpkg install stb pthreads --recurse
- if [%COMPILER%]==[vs] if NOT [%USE_INTEGRATED_LIBS%]==[yes] vcpkg install ffmpeg --recurse
- if [%COMPILER%]==[vs] if NOT [%USE_INTEGRATED_LIBS%]==[yes] vcpkg install opencv[ffmpeg] --recurse ## opencv[ffmpeg,cuda] is too big to build, timing out (>1h). We use plain openCV also for CUDA builds (toolchain can manage this strange situation anyway)
- cd %WORKSPACE%\darknet\
- mkdir build_debug && cd build_debug
- if [%COMPILER%]==[cygwin] mkdir build_debug && cd build_debug
- if [%COMPILER%]==[cygwin] %CYGSH% 'cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Debug"'
- if [%COMPILER%]==[vs] if NOT [%USE_INTEGRATED_LIBS%]==[yes] if [%configuration%]==[Debug] cmake -G "Visual Studio 15 2017" -T "host=x64" -A "x64" "-DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=%VCPKG_DEFAULT_TRIPLET%" -DCMAKE_BUILD_TYPE="Debug" ..
- cd ..
- if [%COMPILER%]==[cygwin] cd ..
- mkdir build_release && cd build_release
- if [%COMPILER%]==[cygwin] %CYGSH% 'cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release"'
- if [%COMPILER%]==[vs] if NOT [%USE_INTEGRATED_LIBS%]==[yes] if [%configuration%]==[Release] cmake -G "Visual Studio 15 2017" -T "host=x64" -A "x64" "-DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=%VCPKG_DEFAULT_TRIPLET%" -DCMAKE_BUILD_TYPE="Release" ..
Expand All @@ -89,7 +78,6 @@ install:
build_script:
- if [%COMPILER%]==[cygwin] cd build_debug && %CYGSH% 'cmake --build . --target install -- -j8' && cd ..
- if [%COMPILER%]==[cygwin] cd build_release && %CYGSH% 'cmake --build . --target install -- -j8' && cd ..
- if [%COMPILER%]==[vs] if NOT [%USE_INTEGRATED_LIBS%]==[yes] if [%configuration%]==[Debug] cd build_debug && cmake --build . --config Debug --parallel 8 --target install && cd ..
- if [%COMPILER%]==[vs] if [%configuration%]==[Release] cd build_release && cmake --build . --config Release --parallel 8 --target install && cd ..

artifacts:
Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ then
vcpkg_define="-DCMAKE_TOOLCHAIN_FILE=${vcpkg_path}/scripts/buildsystems/vcpkg.cmake"
vcpkg_triplet_define="-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet"
echo "Found vcpkg in VCPKG_ROOT: ${vcpkg_path}"
additional_defines="-DBUILD_SHARED_LIBS=OFF"
elif [[ ! -z "${WORKSPACE}" ]] && [ -d ${WORKSPACE}/vcpkg ] && [ ! "$bypass_vcpkg" = true ]
then
vcpkg_path="${WORKSPACE}/vcpkg"
vcpkg_define="-DCMAKE_TOOLCHAIN_FILE=${vcpkg_path}/scripts/buildsystems/vcpkg.cmake"
vcpkg_triplet_define="-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet"
echo "Found vcpkg in WORKSPACE/vcpkg: ${vcpkg_path}"
additional_defines="-DBUILD_SHARED_LIBS=OFF"
elif [ ! "$bypass_vcpkg" = true ]
then
(>&2 echo "darknet is unsupported without vcpkg, use at your own risk!")
Expand Down
21 changes: 7 additions & 14 deletions cmake/Modules/FindCUDNN.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ if(NOT CUDNN_LIBRARY)
PATH_SUFFIXES lib lib64 cuda/lib cuda/lib64 lib/x64)
endif()

find_package_handle_standard_args(
CUDNN DEFAULT_MSG CUDNN_INCLUDE_DIR CUDNN_LIBRARY)

if(CUDNN_FOUND)
if(EXISTS "${CUDNN_INCLUDE_DIR}/cudnn.h")
file(READ ${CUDNN_INCLUDE_DIR}/cudnn.h CUDNN_HEADER_CONTENTS)
string(REGEX MATCH "define CUDNN_MAJOR * +([0-9]+)"
CUDNN_VERSION_MAJOR "${CUDNN_HEADER_CONTENTS}")
Expand All @@ -60,21 +57,17 @@ endif()

set(CUDNN_INCLUDE_DIRS ${CUDNN_INCLUDE_DIR})
set(CUDNN_LIBRARIES ${CUDNN_LIBRARY})
if(CUDNN_FOUND)
message(STATUS "Found cuDNN: v${CUDNN_VERSION} (include: ${CUDNN_INCLUDE_DIR}, library: ${CUDNN_LIBRARY})")
endif()
mark_as_advanced(CUDNN_LIBRARY CUDNN_INCLUDE_DIR)

# Register imported libraries:
# 1. If we can find a Windows .dll file (or if we can find both Debug and
# Release libraries), we will set appropriate target properties for these.
# 2. However, for most systems, we will only register the import location and
# include directory.
find_package_handle_standard_args(CUDNN
REQUIRED_VARS CUDNN_INCLUDE_DIR CUDNN_LIBRARY
VERSION_VAR CUDNN_VERSION
)

if(WIN32)
set(CUDNN_DLL_DIR ${CUDNN_INCLUDE_DIR})
list(TRANSFORM CUDNN_DLL_DIR APPEND "/../bin")
message(STATUS "CUDNN_DLL_DIR: ${CUDNN_DLL_DIR}")
find_file(CUDNN_LIBRARY_DLL NAMES cudnn64_7.dll PATHS ${CUDNN_DLL_DIR})
find_file(CUDNN_LIBRARY_DLL NAMES cudnn64_${CUDNN_VERSION_MAJOR}.dll PATHS ${CUDNN_DLL_DIR})
endif()

if( CUDNN_FOUND AND NOT TARGET CuDNN::CuDNN )
Expand Down

0 comments on commit 35346d2

Please sign in to comment.