Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
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
13 changes: 6 additions & 7 deletions cortex-js/src/infrastructure/commanders/shortcuts/run.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ export class RunCommand extends CommandRunner {
exit(1);
}
}

// Check model compatibility on this machine
await checkModelCompatibility(modelId, checkingSpinner);

// If not exist
// Try Pull
if (!(await this.modelsCliUsecases.getModel(modelId))) {
checkingSpinner.succeed('Model not found. Attempting to pull...');
checkingSpinner.succeed();
await this.modelsCliUsecases.pullModel(modelId).catch((e: Error) => {
if (e instanceof ModelNotFoundException)
checkingSpinner.fail('Model does not exist.');
Expand All @@ -73,16 +77,11 @@ export class RunCommand extends CommandRunner {
!Array.isArray(existingModel.files) ||
/^(http|https):\/\/[^/]+\/.*/.test(existingModel.files[0])
) {
checkingSpinner.fail(
`Model is not available`
);
checkingSpinner.fail(`Model is not available`);
process.exit(1);
}
checkingSpinner.succeed('Model found');

// Check model compatibility on this machine
await checkModelCompatibility(modelId);

const engine = existingModel.engine || Engines.llamaCPP;
// Pull engine if not exist
if (
Expand Down
17 changes: 13 additions & 4 deletions cortex-js/src/utils/model-check.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { MIN_CUDA_VERSION } from "@/infrastructure/constants/cortex";
import { getCudaVersion } from "./cuda";
import ora from "ora";

export const checkModelCompatibility = async (modelId: string) => {
export const checkModelCompatibility = async (modelId: string, spinner?: ora.Ora) => {
function log(message: string) {
if (spinner) {
spinner.fail(message);
} else {
console.error(message);
}
}
if (modelId.includes('onnx') && process.platform !== 'win32') {
console.error('The ONNX engine does not support this OS yet.');
log('The ONNX engine does not support this OS yet.');
process.exit(1);
}

if (modelId.includes('tensorrt-llm') ) {
if(process.platform === 'darwin'){
console.error('Tensorrt-LLM models are not supported on this OS');
log('Tensorrt-LLM models are not supported on this OS');
process.exit(1);
}

Expand All @@ -19,11 +27,12 @@ export const checkModelCompatibility = async (modelId: string) => {
const [requiredMajor, requiredMinor] = MIN_CUDA_VERSION.split('.').map(Number);
const isMatchRequired = currentMajor > requiredMajor || (currentMajor === requiredMajor && currentMinor >= requiredMinor);
if (!isMatchRequired) {
console.error(`CUDA version ${version} is not compatible with TensorRT-LLM models. Required version: ${MIN_CUDA_VERSION}`);
log(`CUDA version ${version} is not compatible with TensorRT-LLM models. Required version: ${MIN_CUDA_VERSION}`)
process.exit(1);
}
} catch (e) {
console.error(e.message ?? e);
log(e.message ?? e);
process.exit(1);
}

Expand Down