#include <iostream>
#define CUDA_RUNTIME_CHECK(call) \
{ \
cudaError_t res = (call); \
if (res != cudaSuccess) { \
std::cout << "CUDA Runtime API " << cudaGetErrorName(res) << ": " \
<< cudaGetErrorString(res) << " [" << __FILE__ << ":" << __LINE__ << ']'; \
exit(1); \
} \
}
__global__ void kernel_empty_test() {}
int main() {
void* brr = nullptr;
CUDA_RUNTIME_CHECK(cudaMallocManaged(&brr, 88));
std::cout << brr << std::endl;
memset(brr, 0, 88);
// Remove this line, then the program won't crash.
kernel_empty_test<<<1, 1, 0>>>();
const int32_t* data = static_cast<int32_t*>(brr);
std::cout << data[0];
}
nvcc rua.cu -o rua && ./rua
0x204c80000
[1] 28250 segmentation fault (core dumped) ./rua
Linux 5.10.104-tegra
Inside docker image: l4t-ml:r35.2.1-py3
nvcc 11.4