graphics() nvidia-smi detection improved

This commit is contained in:
Sebastian Hildebrandt
2021-01-04 07:35:58 +01:00
parent 6aa21ea907
commit e67aa92d56
23 changed files with 40 additions and 25 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
+5
View File
@@ -5,6 +5,11 @@
// ==================================================================================
// cli.js
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
// ==================================================================================
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
+10 -6
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
@@ -378,11 +378,15 @@ function graphics(callback) {
if (_windows) {
try {
const basePath = util.WINDIR + '\\System32\\DriverStore\\FileRepository';
const dirContent = fs.readdirSync(basePath);
const candidateDirs = dirContent.filter(dir => dir.startsWith('nv'));
const targetDir = candidateDirs.find(dir => {
const content = fs.readdirSync([basePath, dir].join('/'));
return content.includes('nvidia-smi.exe');
// find all directories that have an nvidia-smi.exe file
const candidateDirs = fs.readdirSync(basePath).filter(dir => {
return fs.readdirSync([basePath, dir].join('/')).includes('nvidia-smi.exe');
});
// use the directory with the most recently created nvidia-smi.exe file
const targetDir = candidateDirs.reduce((prevDir, currentDir) => {
const previousNvidiaSmi = fs.statSync([basePath, prevDir, 'nvidia-smi.exe'].join('/'));
const currentNvidiaSmi = fs.statSync([basePath, currentDir, 'nvidia-smi.exe'].join('/'));
return (previousNvidiaSmi.ctimeMs > currentNvidiaSmi.ctimeMs) ? prevDir : currentDir;
});
if (targetDir) {
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// Contributors: Guillaume Legrain (https://github.com/glegrain)
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT
+1 -1
View File
@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------------
// Description: System Information - library
// for Node.js
// Copyright: (c) 2014 - 2020
// Copyright: (c) 2014 - 2021
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// License: MIT