!$acc exit data delete(formMat) finalize does not free up GPU memory

In the following code the GPU memory is not being freed.

  allocate(formMat(1:(2*data_in%Lpmax+1)*grid%nr,1:nchansmax))

  istat = cudaMemGetInfo(free, total)
  print*,'GPU memory after allocating space for formMat: free, total (GB)'
  print*,free/dble(2**30), total/dble(2**30)

!$acc exit data delete(formMat) finalize
  deallocate(formMat)

  istat = cudaMemGetInfo(free, total)
  print*,'GPU memory after deleting formMat: free, total (GB)'
  print*,free/dble(2**30), total/dble(2**30)

In one of the previous topics I read the following:

Also, given that device allocation is expensive, the compiler runtime doesn’t actually free the device memory. Rather it adds it back to it’s device memory pool and reuses it later. There’s an environment variable that can be used to disable this, if needed.

Which environment variable can be used to disable this?

It’s “NV_ACC_MEM_MANAGE” or “NVCOMPILER_ACC_MEM_MANAGE”. (“PGI_ACC_MEM_MANAGE” will also work). Set to 0 to disable the runtime memory manager.

-Mat

Thanks Mat! It fixed the problem.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.