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/