如何使用CMake查找CUDNN?

9fkzdhlc  于 2022-11-11  发布在  其他
关注(0)|答案(4)|浏览(593)

显然,我正确安装了CUDA和CUDNN,但FindCUDA仍能找到CUDA,而FindCUDNN.cmake却找不到CUDNN

我还应该检查哪些项目才能两柴这个项目?
**操作系统:**Windows 10
可创建版本3.17.2
CUDA版本10.2
CUDNN版本客户端-10.2-Windows 10-x64-v7.6.5.32

CUDA随安装程序安装到 *C:\Program Files\NVIDIA GPU计算工具包\CUDA\v10.2 *
PATH按指示设置x1c 0d1x
CUDNN文件复制到各自的bin、include和lib文件夹中

[cmake] -- Found CUDA: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.2 (found version "10.2") 
[cmake] CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
[cmake]   Could NOT find CUDNN (missing: CUDNN_LIBRARY CUDNN_INCLUDE_DIR)
[cmake] Call Stack (most recent call first):
[cmake]   C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
[cmake]   cmake/FindCUDNN.cmake:90 (find_package_handle_standard_args)
[cmake]   CMakeLists.txt:17 (find_package)

查找CUDNN.cmake:https://gist.github.com/WurmD/26af2940d8dec7cc48d38bc30fd1b3ef

vwkv1x7d

vwkv1x7d1#

...
set "cudaRoot=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.3"
...
-DCUDNN_LIBRARY="%cudaRoot%\lib" ^
-DCUDNN_INCLUDE_DIR="%cudaRoot%\include" ^
...
icomxhvb

icomxhvb2#

我在用Visual Studio 2019编译OpenCV;所以我就假设你也是--因为我累了,而且我刚刚为自己解决了这个问题。
1.确保在“安装”CUDNN后重新启动/重启您的PC
1.对opencv和opencv_contrib进行新的GIT克隆
1.请确保将BUILD文件夹置于opencv目录中
1.设置所需的环境变量;这样的东西,但填写你的路径:

set "CUDA_PATH=............/NVIDIA GPU Computing Toolkit/CUDA/v11.0"
    set "opencvSource=opencv"
    set "opencvExtraModules=opencv_contrib\modules"
    set "opencvBuild=%opencvSource%\build"
    set "compiler=Visual Studio 16 2019"
    set "buildType=Release"
    set "python3_executable=............/AppData/Local/Programs/Python/Python38/python.exe"
    set "python3_include_dir=............/AppData/Local/Programs/Python/Python38/include"
    set "python3_library=............/AppData/Local/Programs/Python/Python38/libs/python38.lib"
    set "python3_numpy_include_dirs=............/AppData/Local/Programs/Python/Python38/Lib/site-packages/numpy/core/include"
    set "python3_packages_path=............/AppData/Local/Programs/Python/Python38/Lib/site-packages"

1.重新运行CMAKE(显然要更改此选项以匹配您的选项),我的选项是:

cmake ^
    -B"%opencvBuild%/" ^
    -H"%opencvSource%/" ^
    -G"%compiler%" ^
    -Ax64 ^
    -DCMAKE_BUILD_TYPE=%buildType% ^
    -DBUILD_opencv_python3=ON ^
    -DBUILD_opencv_world=ON ^
    -DBUILD_EXAMPLES=OFF ^
    -DBUILD_opencv_python_bindings_generator=ON ^
    -DOPENCV_PYTHON3_VERSION=3.8.3 ^
    -DPYTHON3_EXECUTABLE="%python3_executable%" ^
    -DPYTHON3_INCLUDE_DIR="%python3_include_dir%" ^
    -DPYTHON3_LIBRARY="%python3_library%" ^
    -DPYTHON3_NUMPY_INCLUDE_DIRS="%python3_numpy_include_dirs%" ^
    -DPYTHON3_PACKAGES_PATH="%python3_packages_path%" ^
    -DINSTALL_TESTS=OFF ^
    -DINSTALL_C_EXAMPLES=OFF ^
    -DOPENCV_EXTRA_MODULES_PATH="%opencvExtraModules%/" ^
    -DWITH_CUDA=ON ^
    -DCUDA_ARCH_BIN=6.1^
    -DCUDA_ARCH_PTX=7.5^
    -DCUDA_FAST_MATH=ON ^
    -DBUILD_PROTOBUF=ON
huwehgph

huwehgph3#

在全新安装CuDNN时,请确保通过“文件”和“删除缓存”来删除CMake该高速缓存。这将删除所有设置,但会识别CuDNN。

deikduxw

deikduxw4#

我也遇到过这个问题。从Win32到x64的改变为我解决了这个问题。我猜它在尝试为Win32构建时会寻找不同的路径。

相关问题