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

Commit c3c3946

Browse files
committed
chore: update download path for cuda-toolkit-deps
1 parent e59f86a commit c3c3946

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

engine/commands/engine_init_cmd.cc

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "utils/archive_utils.h"
88
#include "utils/system_info_utils.h"
99
// clang-format on
10-
#include "utils/cortex_utils.h"
1110
#include "utils/cuda_toolkit_utils.h"
1211
#include "utils/engine_matcher_utils.h"
1312
#include "utils/file_manager_utils.h"
@@ -125,6 +124,11 @@ bool EngineInitCmd::Exec() const {
125124
return true;
126125
}
127126

127+
if (cuda_driver_version.empty()) {
128+
CTL_WRN("No cuda driver, continue with CPU");
129+
return true;
130+
}
131+
128132
// download cuda toolkit
129133
const std::string jan_host = "https://catalog.jan.ai";
130134
const std::string cuda_toolkit_file_name = "cuda.tar.gz";
@@ -164,35 +168,30 @@ bool EngineInitCmd::Exec() const {
164168
<< cuda_driver_version << "/" << system_info.os
165169
<< "/" << cuda_toolkit_file_name;
166170

167-
LOG_DEBUG << "Cuda toolkit download url: " << jan_host
171+
LOG_DEBUG << "Cuda toolkit download url: "
168172
<< cuda_toolkit_url.str();
169-
auto cuda_toollkit_local_path =
170-
file_manager_utils::GetExecutableFolderContainerPath() /
173+
auto cuda_toolkit_local_path =
174+
file_manager_utils::GetContainerFolderPath(
175+
file_manager_utils::DownloadTypeToString(
176+
DownloadType::CudaToolkit)) /
171177
cuda_toolkit_file_name;
178+
LOG_DEBUG << "Download to: " << cuda_toolkit_local_path.string();
172179
auto downloadCudaToolkitTask{DownloadTask{
173180
.id = download_id,
174181
.type = DownloadType::CudaToolkit,
175182
.items = {DownloadItem{.id = download_id,
176183
.downloadUrl = cuda_toolkit_url.str(),
177-
.localPath = cuda_toollkit_local_path}},
184+
.localPath = cuda_toolkit_local_path}},
178185
}};
179186

180187
download_service.AddDownloadTask(
181188
downloadCudaToolkitTask, [&](const DownloadTask& finishedTask) {
182-
// TODO(any) This is a temporary fix. The issue will be fixed when we has CIs
183-
// to pack CUDA dependecies into engine release
184-
auto get_engine_path = [](std::string_view e) {
185-
if (e == "cortex.llamacpp") {
186-
return cortex_utils::kLlamaLibPath;
187-
} else {
188-
return cortex_utils::kTensorrtLlmPath;
189-
}
190-
};
191-
std::string engine_path =
192-
file_manager_utils::GetCortexDataPath().string() +
193-
get_engine_path(engineName_);
189+
auto engine_path =
190+
file_manager_utils::GetEnginesContainerPath() /
191+
engineName_;
194192
archive_utils::ExtractArchive(
195-
finishedTask.items[0].localPath.string(), engine_path);
193+
finishedTask.items[0].localPath.string(),
194+
engine_path.string());
196195

197196
try {
198197
std::filesystem::remove(finishedTask.items[0].localPath);

engine/utils/file_manager_utils.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,24 +229,24 @@ inline std::filesystem::path GetEnginesContainerPath() {
229229

230230
inline std::filesystem::path GetContainerFolderPath(
231231
const std::string_view type) {
232-
const auto current_path{GetExecutableFolderContainerPath()};
233-
auto container_folder_path = std::filesystem::path{};
232+
std::filesystem::path container_folder_path;
234233

235234
if (type == "Model") {
236235
container_folder_path = GetModelsContainerPath();
237236
} else if (type == "Engine") {
238237
container_folder_path = GetEnginesContainerPath();
239238
} else if (type == "CudaToolkit") {
240-
container_folder_path = current_path;
239+
container_folder_path =
240+
std::filesystem::temp_directory_path() / "cuda-dependencies";
241241
} else if (type == "Cortex") {
242242
container_folder_path = std::filesystem::temp_directory_path() / "cortex";
243243
} else {
244-
container_folder_path = current_path / "misc";
244+
container_folder_path = std::filesystem::temp_directory_path() / "misc";
245245
}
246246

247247
if (!std::filesystem::exists(container_folder_path)) {
248248
CTL_INF("Creating folder: " << container_folder_path.string() << "\n");
249-
std::filesystem::create_directory(container_folder_path);
249+
std::filesystem::create_directories(container_folder_path);
250250
}
251251

252252
return container_folder_path;

0 commit comments

Comments
 (0)