cuda build_error ai_generated true

运行时错误:NVRTC 编译失败:错误:无法打开源文件 'cuda_runtime.h'

RuntimeError: NVRTC compilation failed: error: cannot open source file 'cuda_runtime.h'

ID: cuda/nvrtc-include-path-missing

其他格式: JSON · Markdown 中文 · English
90%修复率
87%置信度
1证据数
2023-09-05首次发现

版本兼容性

版本状态引入弃用备注
CUDA 11.8 active
CUDA 12.0 active
PyTorch 2.1 active
TensorFlow 2.13 active

根因分析

NVRTC(CUDA 运行时编译)找不到 CUDA 包含路径,因为 CUDA 工具包头文件不在默认搜索路径中,或者 CUDA_HOME 环境变量未正确设置。

English

NVRTC (CUDA runtime compilation) cannot find the CUDA include path because the CUDA toolkit headers are not in the default search path or the CUDA_HOME environment variable is not set correctly.

generic

官方文档

https://docs.nvidia.com/cuda/nvrtc/index.html

解决方案

  1. Set the CUDA_HOME environment variable to the root of your CUDA installation (e.g., /usr/local/cuda-12.1) before running the script. For Python, add it in the code using os.environ.
  2. Create a symlink from the CUDA toolkit include directory to a standard location, or add it to the CPLUS_INCLUDE_PATH environment variable.

无效尝试

常见但无效的做法:

  1. 90% 失败

    NVRTC relies on the system's CUDA installation, not the deep learning framework's bundled headers; reinstalling the framework does not fix the include path.

  2. 70% 失败

    This may work temporarily but breaks portability and version compatibility; also other headers may be missing.