c++ - 如何判断cudaErrorIllegalAddress是由于目标地址还是源地址?

标签 c++ error-handling cuda memory-corruption

documentation for cudaErrorIllegalAddress说:

The device encountered a load or store instruction on an invalid memory address. This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched.

在我的 C++ 代码中,我调用了:

cudaMemcpy( dst, src, size, kind );

如何判断是dst还是src是无效内存?


运行 cuda-memcheck 报告没有错误,valgrind 报告没有错误。鉴于此崩溃仅在使用 -g -G 构建时发生,我可以采取哪些步骤来进一步调试?设备代码中是否有一种方法可以检查是否发生了 cudaErrorIllegalAddress,以便我可以分而治之,解决设备代码中失败的地方?

最佳答案

答案都不是。根据 documentation , cudaMemcpy 本身只会返回三个状态代码之一:

cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidMemcpyDirection

但是,文档还指出了以下内容:

Note that this function may also return error codes from previous, asynchronous launches.

这就是错误的可能来源,即先前的内核正在产生运行时错误,然后由阻塞 API 调用报告。

关于c++ - 如何判断cudaErrorIllegalAddress是由于目标地址还是源地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55405161/

相关文章:

c++ - 将 txt 文件中每一行的 4 个值存储到一个对象中 - C++

powershell - 使用PowerShell的Measure-Command时如何准确报告错误

c++ - 为什么在没有 CUDA __device__ 属性的情况下定义类头有效? (C++)

c - 岩浆2.0错误: CUDA driver version is insufficient for CUDA runtime version

c++ - X3,什么是attr_gen?

c++ - 使用 32 位 Mersenne Twister 生成 64 位值

c++ - 仅输出重载 C++

php - PHP fatal error : Uncaught exception 'Zend_Mail_Protocol_Exception' with message '501 <>: missing or malformed local part

python - 如果找不到元素或 Selenium 等待函数中发生超时异常,如何跳到下一个 url

c++ - Long Long 数据类型的 Cuda 算术除法错误