2016-06-15 48 views
2

我正在嘗試編寫一個python腳本來確定哪個GPU(專用或集成的)當前正在運行。我已經設法通過運行dxdiag並解析每個gpu設備的模式輸出來實現目前的工作,但是這太耗時了。有誰知道dxdiag如何獲取這些信息?有沒有辦法通過Windows管理工具獲取信息?任何幫助表示讚賞。確定什麼GPU通過WMI運行

感謝

回答

1

DXDiag可能WMI表拿起數據。 我需要確認它。

wmic PATH Win32_VideoController GET Adapterram 

將爲您提供您正在尋找的信息。如果您需要更多信息,請運行下面提到的命令。

wmic PATH Win32_VideoController 

如果你想GPU名

wmic PATH Win32_VideoController GET Name 

更新

添加一個例子更好地理解。 您可以將下面提到的表格與deviceid對應並獲取信息。

instance of Win32_VideoController 
{ 
    AdapterCompatibility = "Intel Corporation"; 
    AdapterDACType = "Internal"; 
    AdapterRAM = 1073741824; 
    Availability = 3; 
    Caption = "Intel(R) HD Graphics 4600"; 
    ConfigManagerErrorCode = 0; 
    ConfigManagerUserConfig = FALSE; 
    CreationClassName = "Win32_VideoController"; 
    CurrentBitsPerPixel = 32; 
    CurrentHorizontalResolution = 1920; 
    CurrentNumberOfColors = "4294967296"; 
    CurrentNumberOfColumns = 0; 
    CurrentNumberOfRows = 0; 
    CurrentRefreshRate = 59; 
    CurrentScanMode = 4; 
    CurrentVerticalResolution = 1080; 
    Description = "Intel(R) HD Graphics 4600"; 
    DeviceID = "VideoController1"; 
    DitherType = 0; 
    DriverDate = "20150911000000.000000-000"; 
    DriverVersion = "20.19.15.4285"; 
    InfFilename = "oem79.inf"; 
    InfSection = "iHSWD_w10"; 
    InstalledDisplayDrivers = "igdumdim64.dll,igd10iumd64.dll,igd10iumd64.dll,igd12umd64.dll,igdumdim32,igd10iumd32,igd10iumd32,igd12umd32"; 
    MaxRefreshRate = 75; 
    MinRefreshRate = 50; 
    Monochrome = FALSE; 
    Name = "Intel(R) HD Graphics 4600"; 
    PNPDeviceID = "PCI\\VEN_8086&DEV_0412&SUBSYS_18E5103C&REV_06\\3&11583659&0&10"; 
    Status = "OK"; 
    SystemCreationClassName = "Win32_ComputerSystem"; 
    SystemName = "---------"; 
    VideoArchitecture = 5; 
    VideoMemoryType = 2; 
    VideoModeDescription = "1920 x 1080 x 4294967296 colors"; 
    VideoProcessor = "Intel(R) HD Graphics Family"; 
}; 




instance of Win32_PnPEntity 
{ 
    Caption = "Intel(R) HD Graphics 4600"; 
    ClassGuid = "{4d36e968-e325-11ce-bfc1-08002be10318}"; 
    CompatibleID = {"PCI\\VEN_8086&DEV_0412&REV_06", "PCI\\VEN_8086&DEV_0412", "PCI\\VEN_8086&CC_030000", "PCI\\VEN_8086&CC_0300", "PCI\\VEN_8086", "PCI\\CC_030000", "PCI\\CC_0300"}; 
    ConfigManagerErrorCode = 0; 
    ConfigManagerUserConfig = FALSE; 
    CreationClassName = "Win32_PnPEntity"; 
    Description = "Intel(R) HD Graphics 4600"; 
    DeviceID = "PCI\\VEN_8086&DEV_0412&SUBSYS_18E5103C&REV_06\\3&11583659&0&10"; 
    HardwareID = {"PCI\\VEN_8086&DEV_0412&SUBSYS_18E5103C&REV_06", "PCI\\VEN_8086&DEV_0412&SUBSYS_18E5103C", "PCI\\VEN_8086&DEV_0412&CC_030000", "PCI\\VEN_8086&DEV_0412&CC_0300"}; 
    Manufacturer = "Intel Corporation"; 
    Name = "Intel(R) HD Graphics 4600"; 
    PNPClass = "Display"; 
    PNPDeviceID = "PCI\\VEN_8086&DEV_0412&SUBSYS_18E5103C&REV_06\\3&11583659&0&10"; 
    Present = TRUE; 
    Service = "igfx"; 
    Status = "OK"; 
    SystemCreationClassName = "Win32_ComputerSystem"; 
    SystemName = "-------"; 
}; 
+0

似乎有Win32_VideoController的輸出當一個GPU正在運行在其他之間沒有差異,除了MaxRefreshRate = 0並且沒有MinRefreshRate用於GPU不在使用中。這是唯一能告訴的方法嗎?我認爲會有一些類似於DxDiag中的模式值。 – draB1

+0

我不確定你的意思是什麼「GPU正在運行其他」。我用一個例子更新了答案。您可以依靠WMI獲取所有信息。希望能幫助到你。 –

+0

運行dxdiag時,我能夠看到列爲設備的GPU(集成英特爾和專用Nvidia)。當前運行的GPU的當前顯示模式列爲1920x1080 32位60hz,另一個GPU列爲n/a。在運行上述WMI命令時,沒有區分哪個GPU是當前正在使用的字段。除了MaxRefreshRate之外,GPU正在運行或未運行時,所有字段都是相同的。 – draB1