CUDA Graph in Cuda Fortran 2

Hi all,

From https://forums.developer.nvidia.com/t/cuda-graph-in-cuda-fortran/136290/1 Mat has shown us how to create a CUDA Graph through Cuda Stream.

However, before call a kernel, I need to allocate device memory first. I am pretty sure that using CUDA Stream will not know that I need to allocate device memory first before calling a CUDA Kernel.

integer, managed, allocatable :: a(:)
cudaStreamBeginCapture(stream, 0)
allocate(a(10))
call kernel <<<block, thread, 0, stream>>> (a) 
deallocate(a)
cudaStreamEndCapture(stream, graph)

Hi Phoon,

Correct. Device allocation is not associated with a stream and given Graph only captures the events on a stream, there’s not a way to capture allocation as part of a Graph.

-Mat