I am using the pthread library to implement multithreading.
I am in the process of moving my functions that use detectNet to threads so I can handle network communication tasks in the background. The threads do not need to share memory allocated by cudaMalloc().
In the process of doing so, I am receiving a segmentation fault on cudaMalloc().
I’ve read a bit online and found that cudaMalloc() is thread safe.
Below, is a snippet of cudaMalloc(). Sorry if this is a naive question, but should I be doing something different so that I do not get a segmentation fault? The function works just fine when I do not use threads.
In this snippet, I am allocating the memory during initialization so that I can get performance benefits.
uchar3 * img_buffer; int capture_width = 1280; int capture_height = 720; cudaError_t cuda_rtn; cuda_rtn = cudaMalloc((void**) &img_buffer, (size_t) capture_width * sizeof(uchar3) * capture_height);
Any advice is appreciated, thanks.