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

fix: gate onnx and tensorrt-llm run on darwin #837

Merged
merged 4 commits into from
Jul 4, 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
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
Loading