CUDA 错误:不支持的执行亲和性 (cudaErrorUnsupportedExecAffinity)
CUDA error: unsupported exec affinity (cudaErrorUnsupportedExecAffinity)
ID: cuda/cuda-error-unsupported-exec-affinity
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| CUDA 12.3 | active | — | — | — |
| CUDA 12.5 | active | — | — | — |
| NVIDIA Driver 545.23.06 | active | — | — | — |
| NVIDIA Driver 550.54.10 | active | — | — | — |
| PyTorch 2.4.0 | active | — | — | — |
根因分析
应用程序请求的内核执行亲和性(例如通过 cudaLaunchAttributeCooperative 或 cudaFuncAttributeMaxDynamicSharedMemorySize)不受当前 GPU 架构或驱动程序版本支持。
English
The application requested a kernel execution affinity (e.g., via cudaLaunchAttributeCooperative or cudaFuncAttributeMaxDynamicSharedMemorySize) that is not supported by the current GPU architecture or driver version.
官方文档
https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html解决方案
-
Check GPU compute capability and remove unsupported launch attributes. For example, cooperative launch requires sm >= 70: `deviceProp.major * 10 + deviceProp.minor >= 70`.
-
Upgrade to a driver that supports the required execution affinity (e.g., driver 550.54.10 or newer for CUDA 12.5 features).
-
Fall back to a non-cooperative launch by setting `cudaLaunchAttributeCooperative` to 0: `cudaLaunchConfig config; config.attrs[cudaLaunchAttributeCooperative] = 0;`
无效尝试
常见但无效的做法:
-
85% 失败
The error is about execution affinity attributes, not shared memory limits; increasing shared memory may cause other issues but does not resolve the affinity problem.
-
90% 失败
Synchronous execution does not affect launch attributes; the affinity check happens before the kernel is queued, regardless of blocking mode.