Skip to content

Commit

Permalink
chore: update env for cuda toolkit dependencies and tensorrt-llm (#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan authored Jun 19, 2024
1 parent 09e9c4b commit c55cade
Showing 1 changed file with 24 additions and 1 deletion.
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,
);
}
}

0 comments on commit c55cade

Please sign in to comment.