一键难忘头像
关注
[Bug已解决] arch_id.h: error: template constraint not satisfied 编译报错:CUDA 架构不匹配解决方案封面图

[Bug已解决] arch_id.h: error: template constraint not satisfied 编译报错:CUDA 架构不匹配解决方案

[Bug已解决] arch_id.h: error: template constraint not satisfied 编译报错:CUDA 架构不匹配解决方案

一、报错长什么样

当你在编译一个 PyTorch 的自定义 CUDA 扩展(.cu 文件),或者在 pip install 某些带 CUDA 算子的仓库(比如 detectron2xformersflash-attn 的源码编译版本)时,可能会看到类似这样的报错:

/path/to/torch/include/c10/cuda/CUDAGuard.h: ...
/usr/local/cuda/include/arch_id.h: error: template constraint not satisfied

或者更常见地,编译器(nvcc)直接报:

arch_id.h(...) : error: template constraint not satisfied

这个错误不是你的 Python 代码写错了,而是 nvcc 在编译 CUDA 代码时,遇到了「目标 GPU 架构(__CUDA_ARCH__)与某个模板约束不匹配」的情况。换句话说:你让编译器为一个它不认识的、或不支持的 GPU 计算能力(Compute Capability)去生成代码,于是 PyTorch 内部的 arch_id.h 里那段根据架构选择实现

转载自 CSDN-专业IT技术社区

原文链接:https://blog.csdn.net/weixin_52908342/article/details/162906030

文章来源转载

评论

赞0

评论列表

微信小程序
QQ小程序

关于作者

点赞数:0
关注数:0
粉丝:0
文章:0
关注标签:0
加入于:--