获取 GPU 内存总量? [英] Get total amount of GPU memory?

查看:33
本文介绍了获取 GPU 内存总量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is there an easy and reliable way to get the total amount of the physical GPU memory?

我试过这个,但问题是它返回 4096MB,我使用的是 6144MB 的 GTX 780,所以显示不正确.

I have tried this, but the problem is it returns 4096MB and I'm using a GTX 780 with 6144MB, so yeah not displaying correctly.

代码:

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

与 Windows 显示驱动程序模型 (WDDM) 不兼容的硬件返回此类实例的不准确属性值.

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

这就是它返回 4GB 的原因.

That is why it returns 4gb.

您可以尝试使用 CUDAfy.net

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

这篇关于获取 GPU 内存总量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆