似乎Alea没有正确处理类DeviceMemory2D
我检查空闲内存的代码
let getFreeMemory () =
let free = Marshal.AllocHGlobal sizeof<uint64>
let total = Marshal.AllocHGlobal sizeof<uint64>
let freePtr = NativeInterop.NativePtr.ofNativeInt<nativeint> free
let totalPtr = NativeInterop.NativePtr.ofNativeInt<nativeint> total
CUDAInterop.cuMemGetInfo(freePtr, totalPtr)
|> cuSafeCall
let result = NativeInterop.NativePtr.get freePtr 0
Marshal.FreeHGlobal free
Marshal.FreeHGlobal total
uint64 result
这是检查是否存在任何泄漏的代码
Seq.init 100 (fun _ ->
use arr = Gpu.Default.AllocateDevice<float>(1000,1000)
getFreeMemory()
|> printfn "%d"
)
|> Seq.iter id
从输出图像中,内存似乎没有被处理