Skip to content

Commit eb96ed4

Browse files
committed
update ld_library_path
1 parent 1a54729 commit eb96ed4

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

engine/cli/commands/server_start_cmd.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,8 @@ bool ServerStartCmd::Exec(const std::string& host, int port) {
9797
v += g;
9898
}
9999
CTL_INF("LD_LIBRARY_PATH: " << v);
100-
auto data_path = file_manager_utils::GetEnginesContainerPath();
101-
auto llamacpp_path = data_path / "cortex.llamacpp/";
102-
auto trt_path = data_path / "cortex.tensorrt-llm/";
103-
if (!std::filesystem::exists(llamacpp_path)) {
104-
std::filesystem::create_directory(llamacpp_path);
105-
}
100+
auto llamacpp_path = file_manager_utils::GetCudaToolkitPath(kLlamaRepo);
101+
auto trt_path = file_manager_utils::GetCudaToolkitPath(kTrtLlmRepo);
106102

107103
auto new_v = trt_path.string() + ":" + llamacpp_path.string() + ":" + v;
108104
setenv(name, new_v.c_str(), true);

engine/cli/main.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void SetupLogger(trantor::FileLogger& async_logger, bool verbose) {
4848
std::filesystem::path(config.logFolderPath) /
4949
std::filesystem::path(cortex_utils::logs_folder));
5050
async_logger.setFileName(config.logFolderPath + "/" +
51-
cortex_utils::logs_cli_base_name);
51+
cortex_utils::logs_cli_base_name);
5252
async_logger.setMaxLines(config.maxLogLines); // Keep last 100000 lines
5353
async_logger.startLogging();
5454
trantor::Logger::setOutputFunction(
@@ -96,15 +96,20 @@ int main(int argc, char* argv[]) {
9696
}
9797
}
9898

99-
{ file_manager_utils::CreateConfigFileIfNotExist(); }
99+
{
100+
auto result = file_manager_utils::CreateConfigFileIfNotExist();
101+
if (result.has_error()) {
102+
CTL_ERR("Error creating config file: " << result.error());
103+
}
104+
}
100105

101106
RemoveBinaryTempFileIfExists();
102107

103108
trantor::FileLogger async_file_logger;
104109
SetupLogger(async_file_logger, verbose);
105110

106111
if (should_install_server) {
107-
InstallServer();
112+
InstallServer();
108113
return 0;
109114
}
110115

engine/services/engine_service.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ cpp::result<void, std::string> EngineService::InstallEngineAsyncV2(
7676
CTL_INF("InstallEngineAsyncV2: " << ne << ", " << version << ", "
7777
<< variant_name.value_or(""));
7878
auto os = hw_inf_.sys_inf->os;
79-
CTL_INF("os: " << os);
80-
CTL_INF("kMacOs: " << kMacOs);
8179
if (os == kMacOs && (ne == kOnnxRepo || ne == kTrtLlmRepo)) {
8280
return cpp::fail("Engine " + ne + " is not supported on macOS");
8381
}
@@ -88,9 +86,9 @@ cpp::result<void, std::string> EngineService::InstallEngineAsyncV2(
8886

8987
auto result = DownloadEngineV2(ne, version, variant_name);
9088
if (result.has_error()) {
91-
return result;
89+
return cpp::fail(result.error());
9290
}
93-
auto cuda_res = DownloadCuda(ne, true /*async*/);
91+
auto cuda_res = DownloadCuda(ne, true);
9492
if (cuda_res.has_error()) {
9593
return cpp::fail(cuda_res.error());
9694
}
@@ -451,12 +449,12 @@ cpp::result<bool, std::string> EngineService::DownloadCuda(
451449

452450
auto cuda_toolkit_url = url_parser::FromUrl(url_obj);
453451

454-
LOG_DEBUG << "Cuda toolkit download url: " << cuda_toolkit_url;
452+
CTL_DBG("Cuda toolkit download url: " << cuda_toolkit_url);
455453
auto cuda_toolkit_local_path =
456454
file_manager_utils::GetContainerFolderPath(
457455
file_manager_utils::DownloadTypeToString(DownloadType::CudaToolkit)) /
458456
cuda_toolkit_file_name;
459-
LOG_DEBUG << "Download to: " << cuda_toolkit_local_path.string();
457+
CTL_DBG("Download to: " << cuda_toolkit_local_path.string());
460458
auto downloadCudaToolkitTask{DownloadTask{
461459
.id = download_id,
462460
.type = DownloadType::CudaToolkit,
@@ -466,7 +464,7 @@ cpp::result<bool, std::string> EngineService::DownloadCuda(
466464
}};
467465

468466
auto on_finished = [engine](const DownloadTask& finishedTask) {
469-
auto engine_path = file_manager_utils::GetEnginesContainerPath() / engine;
467+
auto engine_path = file_manager_utils::GetCudaToolkitPath(engine);
470468
archive_utils::ExtractArchive(finishedTask.items[0].localPath.string(),
471469
engine_path.string());
472470

engine/utils/file_manager_utils.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,19 @@ inline std::filesystem::path GetModelsContainerPath() {
272272
return models_container_path;
273273
}
274274

275+
inline std::filesystem::path GetCudaToolkitPath(const std::string& engine) {
276+
auto engine_path = getenv("ENGINE_PATH")
277+
? std::filesystem::path(getenv("ENGINE_PATH"))
278+
: GetCortexDataPath();
279+
280+
auto cuda_path = engine_path / "engines" / engine / "deps";
281+
if (!std::filesystem::exists(cuda_path)) {
282+
std::filesystem::create_directories(cuda_path);
283+
}
284+
285+
return cuda_path;
286+
}
287+
275288
inline std::filesystem::path GetEnginesContainerPath() {
276289
auto cortex_path = getenv("ENGINE_PATH")
277290
? std::filesystem::path(getenv("ENGINE_PATH"))

0 commit comments

Comments
 (0)