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

chore: update env for cuda toolkit dependencies and tensorrt-llm #728

Merged
merged 1 commit into from
Jun 19, 2024
Merged
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
25 changes: 24 additions & 1 deletion cortex-js/src/usecases/cortex/cortex.usecases.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { ChildProcess, spawn } from 'child_process';
import { join } from 'path';
import { join, delimiter } from 'path';
import { CortexOperationSuccessfullyDto } from '@/infrastructure/dtos/cortex/cortex-operation-successfully.dto';
import { HttpService } from '@nestjs/axios';
import {
Expand Down Expand Up @@ -45,6 +45,7 @@ export class CortexUsecases {
if (!existsSync(cortexCppPath)) {
throw new Error('The engine is not available, please run "cortex init".');
}
await this.addAdditionalDependencies();

// go up one level to get the binary folder, have to also work on windows
this.cortexProcess = spawn(cortexCppPath, args, {
Expand Down Expand Up @@ -103,4 +104,26 @@ export class CortexUsecases {
})
.catch(() => false);
}

private async addAdditionalDependencies() {
const cortexCPPPath = join(
await this.fileManagerService.getDataFolderPath(),
'cortex-cpp',
);
const additionalLlamaCppPath = delimiter.concat(
join(cortexCPPPath, 'cortex.llamacpp'),
);
const additionalTensortLLMCppPath = delimiter.concat(
join(cortexCPPPath, 'cortex.tensorrt-llm'),
);
const additionalPaths = delimiter.concat(
additionalLlamaCppPath,
additionalTensortLLMCppPath,
);
// Set the updated PATH
process.env.PATH = (process.env.PATH || '').concat(additionalPaths);
process.env.LD_LIBRARY_PATH = (process.env.LD_LIBRARY_PATH || '').concat(
additionalPaths,
);
}
}
Loading