Skip to content

Commit d332b77

Browse files
authored
feat(inspect gpu command): print env info (#202)
1 parent 5ca33c7 commit d332b77

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ body:
5050
attributes:
5151
label: My Environment
5252
description: >-
53-
Please add any other relevant dependencies to this table at the end.
53+
Please include the result of the command `npx --yes node-llama-cpp inspect gpu`.
54+
Please also add any other relevant dependencies to this table at the end.
5455
For example: Electron, Bun, Webpack.
5556
value: |
5657
| Dependency | Version |

src/cli/commands/inspect/commands/InspectGpuCommand.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {detectAvailableComputeLayers} from "../../../../bindings/utils/detectAva
77
import {getPlatform} from "../../../../bindings/utils/getPlatform.js";
88
import {BuildGpu, LlamaLogLevel} from "../../../../bindings/types.js";
99
import {getPrettyBuildGpuName} from "../../../../bindings/consts.js";
10+
import {getModuleVersion} from "../../../../utils/getModuleVersion.js";
1011

1112
type InspectGpuCommand = {
1213
// no options for now
@@ -21,6 +22,29 @@ export const InspectGpuCommand: CommandModule<object, InspectGpuCommand> = {
2122
const availableComputeLayers = await detectAvailableComputeLayers({platform});
2223
const gpusToLogVramUsageOf: BuildGpu[] = [];
2324

25+
console.info(`${chalk.yellow("OS:")} ${os.type()} ${os.release()} ${chalk.dim("(" + os.arch() + ")")}`);
26+
27+
if (process.versions.node != null)
28+
console.info(`${chalk.yellow("Node:")} ${process.versions.node} ${chalk.dim("(" + arch + ")")}`);
29+
30+
if (process.versions.bun != null)
31+
console.info(`${chalk.yellow("Bun:")} ${process.versions.bun}`);
32+
33+
const typeScriptVersion = await getInstalledTypescriptVersion();
34+
if (typeScriptVersion != null)
35+
console.info(`${chalk.yellow("TypeScript:")} ${typeScriptVersion}`);
36+
37+
try {
38+
const moduleVersion = await getModuleVersion();
39+
40+
if (moduleVersion != null)
41+
console.info(`${chalk.yellow("node-llama-cpp:")} ${moduleVersion}`);
42+
} catch (err) {
43+
// do nothing
44+
}
45+
46+
console.info();
47+
2448
if (platform === "mac" && arch === "arm64") {
2549
console.info(`${chalk.yellow("Metal:")} ${chalk.green("available")}`);
2650
gpusToLogVramUsageOf.push("metal");
@@ -101,6 +125,20 @@ function getPercentageString(amount: number, total: number) {
101125
return String(Math.floor((amount / total) * 100 * 100) / 100);
102126
}
103127

128+
async function getInstalledTypescriptVersion() {
129+
try {
130+
const ts = await import("typescript");
131+
const version = ts?.version ?? ts?.default?.version;
132+
133+
if (version != null && typeof version === "string" && version.length > 0)
134+
return version;
135+
136+
return null;
137+
} catch (err) {
138+
return null;
139+
}
140+
}
141+
104142
// // simple script to copy console logs as ansi to clipboard. Used to update the documentation
105143
// import {spawn} from "child_process";
106144
// const pendingLog: string[] = [];

0 commit comments

Comments
 (0)