Hi,
Sometimes when I start the program, no error is reported. Sometimes an error will be reported: CUDA Error: an illegal instruction was encountered. My code is as follows:
if (bgr_cpu_raw_buffer_ == nullptr || bgr_gpu_raw_buffer_ == nullptr) {
cudaHostAlloc(reinterpret_cast<void **>(&bgr_cpu_raw_buffer_),
width_ * height_ * 3 / 2, cudaHostAllocMapped);
cudaHostGetDevicePointer(
reinterpret_cast<void **>(&bgr_gpu_raw_buffer_),
reinterpret_cast<void *>(bgr_cpu_raw_buffer_), 0);
}
memcpy(bgr_cpu_raw_buffer_, av_frame_decode_->data[0], size0);
memcpy(bgr_cpu_raw_buffer_ + size0, av_frame_decode_->data[1], size1);
memcpy(bgr_cpu_raw_buffer_ + size0 + size1, av_frame_decode_->data[2],
size2);
cuda_error = senseAD::adHal::cudaYUV420PToBGR(
bgr_gpu_raw_buffer_, bgr_gpu_out, width_, height_,
av_frame_decode_->linesize);
if (cuda_error != cudaSuccess) {
AD_LERROR(FFmpegH264Decoder)
<< "CUDA Error: " << cudaGetErrorString(cuda_error);
}
This error occurs randomly, but the probability of occurrence is quite high.
cudaError_t cudaYUV420PToBGR(unsigned char *inputYUV,
unsigned char *output,
size_t width,
size_t height,
int linesize[3],
cudaStream_t stream) {
if (!inputYUV || !output) {
return cudaErrorInvalidDevicePointer;
}
if (width == 0 || height == 0) {
return cudaErrorInvalidValue;
}
unsigned int blockSize = 1024;
unsigned int numBlocks = (width / 2 + blockSize - 1) / blockSize;
YUV420PToBGR<<<numBlocks, blockSize>>>(
inputYUV, output, width, height, linesize[0], linesize[1], linesize[2]);
return cudaGetLastError();
}