public ulong GetTotalMemory(int gpuIndex) { try { if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex)) { return(0); } ADLMemoryInfo info = new ADLMemoryInfo(); var r = AdlNativeMethods.ADL_Adapter_MemoryInfo_Get(adapterIndex, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL_Adapter_MemoryInfo_Get)} {r.ToString()}"); return(0); } return(info.MemorySize); } catch { return(0); } }