(openpose) root@cnshaw2404:~/Documents/openpose/build# cmake .. -DBUILD_PYTHON=true -DUSE_CUDNN=off CMake Warning (dev) at CMakeLists.txt:19 (project): cmake_minimum_required() should be called prior to this top-level project() call. Please see the cmake-commands(7) manual for usage documentation of both commands. This warning is for project developers. Use -Wno-dev to suppress it. CMake Deprecation Warning at CMakeLists.txt:34 (cmake_minimum_required): Compatibility with CMake < 3.10 will be removed from a future version of CMake. Update the VERSION argument <min> value. Or, use the <min>...<max> syntax to tell CMake that the project requires at least <min> but has been updated to work with policies introduced by <max> or earlier. -- GCC detected, adding compile flags -- GCC detected, adding compile flags CMake Warning (dev) at CMakeLists.txt:214 (find_package): Policy CMP0146 is not set: The FindCUDA module is removed. Run "cmake --help-policy CMP0146" for policy details. Use the cmake_policy command to set the policy and suppress this warning. This warning is for project developers. Use -Wno-dev to suppress it. -- Building with CUDA. CMake Warning (dev) at CMakeLists.txt:353 (find_package): Policy CMP0146 is not set: The FindCUDA module is removed. Run "cmake --help-policy CMP0146" for policy details. Use the cmake_policy command to set the policy and suppress this warning. This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at cmake/Cuda.cmake:282 (find_package): Policy CMP0146 is not set: The FindCUDA module is removed. Run "cmake --help-policy CMP0146" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Call Stack (most recent call first): CMakeLists.txt:424 (include) This warning is for project developers. Use -Wno-dev to suppress it. -- CUDA detected: 11.8 -- Added CUDA NVCC flags for: sm_86 -- cuDNN not found -- Found gfl
时间: 2025-07-06 15:32:15 浏览: 11
<think>嗯,用户正在尝试解决OpenPose构建过程中的CMake警告问题。他提到的几个关键词包括CUDNN、FindCUDA已弃用、GCC与CUDA的兼容性。我需要结合这些点来提供解决方案。
首先,用户提到了CMake警告,特别是关于FindCUDA模块被弃用。我记得CMake在较新版本中推荐使用CMake内置的CUDA支持,而不是旧的FindCUDA。可能需要建议用户更新他们的CMakeLists.txt,替换掉find_package(CUDA)的用法,转而启用语言支持,比如使用enable_language(CUDA)。这样可以利用CMake对CUDA的原生支持,避免警告。引用中的资料提到CMake用于生成makefile,所以正确配置CMake是关键。[^3]
接下来是CUDNN的问题。用户可能在配置时没有正确指定CUDNN的路径。通常,这需要设置CUDNN的包含路径和库路径。建议用户检查CUDNN的安装位置,并通过CMake变量如CUDNN_INCLUDE和CUDNN_LIBRARY来明确指定。例如,在CMake命令中添加-DCUDNN_INCLUDE=/path/to/cudnn/include和-DCUDNN_LIBRARY=/path/to/cudnn/lib64/libcudnn.so。这可能帮助CMake正确找到CUDNN,避免相关警告。[^4]
然后是GCC与CUDA的兼容性问题。不同版本的CUDA支持的GCC版本不同。例如,CUDA 11.0可能要求GCC版本不超过9。用户需要检查他们的GCC版本是否符合CUDA的要求。如果版本不匹配,可能需要降级GCC或者升级CUDA。此外,如果用户必须使用特定GCC版本,可以在CMake中指定编译器路径,比如设置-DCMAKE_C_COMPILER=/usr/bin/gcc-8和-DCMAKE_CXX_COMPILER=/usr/bin/g++-8。同时,调整nvcc的编译标志,例如添加-gencode arch=compute_xx,code=sm_xx来指定计算能力,可能解决兼容性警告。[^1]
另外,用户可能没有更新子模块,导致依赖问题。OpenPose可能有子模块需要初始化,所以运行git submodule update --init --recursive是必要的步骤,这能确保所有依赖项正确加载,避免构建错误。
还有,构建目录可能存在旧的缓存文件,导致配置错误。建议用户删除build目录并重新生成,例如使用rm -rf build && cmake -B build,这可以清除旧的配置,减少警告出现的可能性。
关于BoringSSL的引用,虽然OpenPose可能不直接相关,但依赖管理是类似的。确保所有依赖项正确嵌入或安装,避免缺失库导致的警告。[^5]
总结下来,解决方案步骤包括:更新CMake配置以使用新的CUDA支持,正确指定CUDNN路径,调整GCC版本,清理构建目录,初始化子模块,以及处理弃用警告。需要一步步引导用户检查每个部分,确保配置正确。同时,引用相关的资料来支持建议,比如CMake的使用和编译器选项。</think>以下是解决OpenPose构建过程中CMake警告的逐步解决方案:
### 一、CUDA相关警告处理
1. **FindCUDA模块弃用警告**
在CMakeLists.txt中替换旧的CUDA配置方式:
```cmake
# 旧方法(已弃用)
find_package(CUDA REQUIRED)
# 新方法(CMake 3.8+)
enable_language(CUDA)
set(CMAKE_CUDA_STANDARD 14)
```
此方法通过CMake原生CUDA支持消除警告
2. **CUDNN路径配置**
在CMake命令中显式指定CUDNN路径:
```bash
cmake -B build -DCUDNN_INCLUDE=/usr/local/cuda/include \
-DCUDNN_LIBRARY=/usr/local/cuda/lib64/libcudnn.so
```
### 二、编译器兼容性处理
3. **GCC与CUDA版本匹配**
| CUDA版本 | 最大支持GCC版本 |
|----------|----------------|
| CUDA 11 | GCC 10 |
| CUDA 10 | GCC 8 |
强制指定编译器版本:
```bash
cmake -B build -DCMAKE_C_COMPILER=/usr/bin/gcc-9 \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-9
```
4. **NVCC警告抑制**
在CMakeLists.txt中添加:
```cmake
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
```
### 三、构建环境清理
5. **清除旧构建缓存**
```bash
rm -rf build && mkdir build
```
6. **完整构建命令示例**
```bash
git submodule update --init --recursive # 更新子模块
cmake -B build -DCMAKE_BUILD_TYPE=Release \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda
cmake --build build --parallel $(nproc)
```
阅读全文
相关推荐















