mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: This is a first step towards creating context manager that errors out on synchronizing calls. Pull Request resolved: https://github.com/pytorch/pytorch/pull/61889 Reviewed By: albanD Differential Revision: D29805280 Pulled By: ngimel fbshipit-source-id: b66400fbe0941b7daa51e6b30abe27b9cccd4e8a
21 lines
621 B
C++
21 lines
621 B
C++
#include <c10/cuda/CUDAMiscFunctions.h>
|
|
#include <stdlib.h>
|
|
|
|
namespace c10 {
|
|
namespace cuda {
|
|
|
|
const char* get_cuda_check_suffix() noexcept {
|
|
static char* device_blocking_flag = getenv("CUDA_LAUNCH_BLOCKING");
|
|
static bool blocking_enabled =
|
|
(device_blocking_flag && atoi(device_blocking_flag));
|
|
if (blocking_enabled) {
|
|
return "";
|
|
} else {
|
|
return "\nCUDA kernel errors might be asynchronously reported at some"
|
|
" other API call,so the stacktrace below might be incorrect."
|
|
"\nFor debugging consider passing CUDA_LAUNCH_BLOCKING=1.";
|
|
}
|
|
}
|
|
} // namespace cuda
|
|
} // namespace c10
|