Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(inspect gpu command): print env info #202

Merged
merged 2 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ body:
attributes:
label: My Environment
description: >-
Please add any other relevant dependencies to this table at the end.
Please include the result of the command `npx --yes node-llama-cpp inspect gpu`.
Please also add any other relevant dependencies to this table at the end.
For example: Electron, Bun, Webpack.
value: |
| Dependency | Version |
Expand Down
38 changes: 38 additions & 0 deletions src/cli/commands/inspect/commands/InspectGpuCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {detectAvailableComputeLayers} from "../../../../bindings/utils/detectAva
import {getPlatform} from "../../../../bindings/utils/getPlatform.js";
import {BuildGpu, LlamaLogLevel} from "../../../../bindings/types.js";
import {getPrettyBuildGpuName} from "../../../../bindings/consts.js";
import {getModuleVersion} from "../../../../utils/getModuleVersion.js";

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

console.info(`${chalk.yellow("OS:")} ${os.type()} ${os.release()} ${chalk.dim("(" + os.arch() + ")")}`);

if (process.versions.node != null)
console.info(`${chalk.yellow("Node:")} ${process.versions.node} ${chalk.dim("(" + arch + ")")}`);

if (process.versions.bun != null)
console.info(`${chalk.yellow("Bun:")} ${process.versions.bun}`);

const typeScriptVersion = await getInstalledTypescriptVersion();
if (typeScriptVersion != null)
console.info(`${chalk.yellow("TypeScript:")} ${typeScriptVersion}`);

try {
const moduleVersion = await getModuleVersion();

if (moduleVersion != null)
console.info(`${chalk.yellow("node-llama-cpp:")} ${moduleVersion}`);
} catch (err) {
// do nothing
}

console.info();

if (platform === "mac" && arch === "arm64") {
console.info(`${chalk.yellow("Metal:")} ${chalk.green("available")}`);
gpusToLogVramUsageOf.push("metal");
Expand Down Expand Up @@ -101,6 +125,20 @@ function getPercentageString(amount: number, total: number) {
return String(Math.floor((amount / total) * 100 * 100) / 100);
}

async function getInstalledTypescriptVersion() {
try {
const ts = await import("typescript");
const version = ts?.version ?? ts?.default?.version;

if (version != null && typeof version === "string" && version.length > 0)
return version;

return null;
} catch (err) {
return null;
}
}

// // simple script to copy console logs as ansi to clipboard. Used to update the documentation
// import {spawn} from "child_process";
// const pendingLog: string[] = [];
Expand Down