c# - 获取 GPU 显存总量?

标签 c# .net wmi

是否有一种简单可靠的方法来获取物理 GPU 显存总量?

我试过了,但问题是它返回 4096MB,而我使用的是 GTX 780 和 6144MB,所以显示不正确。

代码:

using System.Management;        

private void getGpuMem()
{
    ManagementClass c = new ManagementClass("Win32_VideoController");
    foreach (ManagementObject o in c.GetInstances())
    {
        string gpuTotalMem = String.Format("{0} ", o["AdapterRam"]);
        Debug.Write(gpuTotalMem);
    }
}

最佳答案

正如MSDN中所说

Hardware that is not compatible with Windows Display Driver Model (WDDM) returns inaccurate property values for instances of this class.

这就是它返回 4gb 的原因。

你可以尝试使用CUDAfy.net

GPGPU gpu = CudafyHost.GetDevice(CudafyModes.Target, CudafyModes.DeviceId);
var c = gpu.GetDeviceProperties(true);
var p = c.TotalMemory;
Console.WriteLine(p);

关于c# - 获取 GPU 显存总量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37601105/

相关文章:

c# - 混合模型优先和代码优先

c# - Oxyplot:为 Oxyplot 的热图设置边距/填充

c# - protobuf-net:序列化一个空列表

.net - 如何调用作为 .Net 程序集中嵌入资源的 exe?

c# - 在构造函数中使用 Mapper.Initialize

c# - 抛出类型为 'System.OutOfMemoryException' 的异常。使用 IDataReader 时的 C#

powershell - PowerShell返回类型

.net - 如何提高 .NET 中的 WMI 性能?

.net - 从 WCF REST 获取错误详细信息

c# - WMI 太慢了