我似乎无法找到为什么这段代码会给我System.BadImageFormatException:对内存位置的无效访问
public unsafe static ulong FreeMemory()
{
unsafe
{
var free = Marshal.AllocHGlobal(sizeof(ulong));
var total = Marshal.AllocHGlobal(sizeof(ulong));
ulong result = 0;
var freePtr = &free;
var totalPtr = &total;
CUDAInterop.cuMemGetInfo(freePtr, totalPtr);
result = (ulong)freePtr[0];
Marshal.FreeHGlobal(free);
Marshal.FreeHGlobal(total);
return result;
}
}