Skip to content

Commit 7c727fb

Browse files
authored
arg : add --no-mmproj-offload (#13093)
* arg : add --no-mmproj-offload * Update common/arg.cpp
1 parent 80982e8 commit 7c727fb

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

common/arg.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,13 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
21402140
params.no_mmproj = true;
21412141
}
21422142
).set_examples(mmproj_examples));
2143+
add_opt(common_arg(
2144+
{"--no-mmproj-offload"},
2145+
"do not offload multimodal projector to GPU",
2146+
[](common_params & params) {
2147+
params.mmproj_use_gpu = false;
2148+
}
2149+
).set_examples(mmproj_examples));
21432150
add_opt(common_arg(
21442151
{"--image"}, "FILE",
21452152
"path to an image file. use with multimodal models. Specify multiple times for batching",

common/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ struct common_params {
342342

343343
// multimodal models (see examples/llava)
344344
struct common_params_model mmproj;
345+
bool mmproj_use_gpu = true; // use GPU for multimodal model
345346
bool no_mmproj = false; // explicitly disable multimodal model
346347
std::vector<std::string> image; // path to image file(s)
347348

examples/llava/mtmd-cli.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ static void show_additional_info(int /*argc*/, char ** argv) {
4040
"Usage: %s [options] -m <model> --mmproj <mmproj> --image <image> -p <prompt>\n\n"
4141
" -m and --mmproj are required\n"
4242
" -hf user/repo can replace both -m and --mmproj in most cases\n"
43-
" --image and -p are optional, if NOT provided, the CLI will run in chat mode\n",
43+
" --image and -p are optional, if NOT provided, the CLI will run in chat mode\n"
44+
" to disable using GPU for mmproj model, add --no-mmproj-offload\n",
4445
argv[0]
4546
);
4647
}
@@ -112,10 +113,10 @@ struct mtmd_cli_context {
112113
void init_vision_context(common_params & params) {
113114
const char * clip_path = params.mmproj.path.c_str();
114115
ctx_vision.reset(mtmd_init_from_file(clip_path, model, mtmd_context_params{
115-
/* use_gpu */ true,
116+
/* use_gpu */ params.mmproj_use_gpu,
116117
/* timings */ true,
117118
/* n_threads */ params.cpuparams.n_threads,
118-
/* verbosity */ GGML_LOG_LEVEL_INFO,
119+
/* verbosity */ params.verbosity > 0 ? GGML_LOG_LEVEL_DEBUG : GGML_LOG_LEVEL_INFO,
119120
}));
120121
if (!ctx_vision.get()) {
121122
LOG_ERR("Failed to load vision model from %s\n", clip_path);

0 commit comments

Comments
 (0)