Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit c55cade

Browse files
authored
chore: update env for cuda toolkit dependencies and tensorrt-llm (#728)
1 parent 09e9c4b commit c55cade

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

cortex-js/src/usecases/cortex/cortex.usecases.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Injectable } from '@nestjs/common';
22
import { ChildProcess, spawn } from 'child_process';
3-
import { join } from 'path';
3+
import { join, delimiter } from 'path';
44
import { CortexOperationSuccessfullyDto } from '@/infrastructure/dtos/cortex/cortex-operation-successfully.dto';
55
import { HttpService } from '@nestjs/axios';
66
import {
@@ -45,6 +45,7 @@ export class CortexUsecases {
4545
if (!existsSync(cortexCppPath)) {
4646
throw new Error('The engine is not available, please run "cortex init".');
4747
}
48+
await this.addAdditionalDependencies();
4849

4950
// go up one level to get the binary folder, have to also work on windows
5051
this.cortexProcess = spawn(cortexCppPath, args, {
@@ -103,4 +104,26 @@ export class CortexUsecases {
103104
})
104105
.catch(() => false);
105106
}
107+
108+
private async addAdditionalDependencies() {
109+
const cortexCPPPath = join(
110+
await this.fileManagerService.getDataFolderPath(),
111+
'cortex-cpp',
112+
);
113+
const additionalLlamaCppPath = delimiter.concat(
114+
join(cortexCPPPath, 'cortex.llamacpp'),
115+
);
116+
const additionalTensortLLMCppPath = delimiter.concat(
117+
join(cortexCPPPath, 'cortex.tensorrt-llm'),
118+
);
119+
const additionalPaths = delimiter.concat(
120+
additionalLlamaCppPath,
121+
additionalTensortLLMCppPath,
122+
);
123+
// Set the updated PATH
124+
process.env.PATH = (process.env.PATH || '').concat(additionalPaths);
125+
process.env.LD_LIBRARY_PATH = (process.env.LD_LIBRARY_PATH || '').concat(
126+
additionalPaths,
127+
);
128+
}
106129
}

0 commit comments

Comments
 (0)