You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu20+CUDA11编译Caffe时遇cudaGetDeviceProperties_v2未定义引用错误

解决Ubuntu 20 + CUDA 11编译Caffe时cudaGetDeviceProperties_v2未定义引用的问题
  • 替换旧版CUDA API调用
    CUDA 11已经废弃了带_v2后缀的旧版设备属性查询API,直接把代码中所有cudaGetDeviceProperties_v2替换成cudaGetDeviceProperties即可。可以用命令全局搜索替换:

    grep -r "cudaGetDeviceProperties_v2" ./caffe-source-dir/
    sed -i 's/cudaGetDeviceProperties_v2/cudaGetDeviceProperties/g' ./caffe-source-dir/$(grep -r "cudaGetDeviceProperties_v2" ./caffe-source-dir/ | cut -d: -f1)
    
  • 修正Makefile.config中的CUDA配置
    打开Makefile.config,确保以下配置正确指向CUDA 11的路径和支持的GPU架构:

    CUDA_INCLUDE_DIRS := /usr/local/cuda-11.x/include
    CUDA_LIB_DIRS := /usr/local/cuda-11.x/lib64
    # 根据你的GPU型号调整,比如RTX 20/30系列用compute_75,40系列用compute_89
    CUDA_ARCH := -gencode arch=compute_75,code=sm_75 \
                 -gencode arch=compute_80,code=sm_80 \
                 -gencode arch=compute_86,code=sm_86
    
  • 确认链接阶段正确关联CUDA库
    检查Makefile中的LIBRARIES配置,确保包含cudart等必要的CUDA库:

    LIBRARIES += cudart cublas curand
    
  • 清理缓存重新编译
    先清除旧的编译产物,避免缓存干扰,再重新编译:

    make clean
    make all -j$(nproc)
    
  • 适配CUDA 11的分支/补丁
    如果官方原版Caffe对CUDA 11支持不足,可以切换到社区维护的适配CUDA 11的分支,或者应用对应的适配补丁,解决API兼容性问题。

内容的提问来源于stack exchange,提问作者Planck35

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 21:57:06