How do I get the address of cv::cuda::GpuMat?

for (int batch_idx = 0; batch_idx < _batch_size; ++batch_idx)
{
	letterbox(images[batch_idx], blob_imgs_host[batch_idx], size);
	cv::cuda::GpuMat blob_img_GPU;
	blob_img_GPU.upload(blob_imgs_host[batch_idx]);
	cout << "pointer_host:" << blob_imgs_host[batch_idx].ptr<float>() << endl;
	CHECK(cudaMemcpyAsync(
		(char *)_device_ptrs[0] + batch_idx * total_elements * blob_img_GPU.elemSize(),
		blob_img_GPU.ptr<float>(),
		total_elements * blob_img_GPU.elemSize(),
		cudaMemcpyDeviceToDevice,
		_stream));
}

When I use function cudaMemcpyAsync copy memory DeviceToDevice,the second parameters need to pass the device address of blob_img_GPU,How should I specify it? In my code, I use blob_img_GPU.ptr(),but it is fault. When I run the codeļ¼Œerror with invalid argument.

Hi,

Have you tried to use blob_img_GPU.data instead ? There is also datastart and dataend ptr. Warning: The pointer is not a RAM pointer but a VRAM pointer, meaning your CPU cannot read the value at this location.

More details