Skip to content

Commit 6427ce9

Browse files
committed
[Fix] Compiling clip-quantize-cli and running it in a CUDA environment will cause ggml_fp16_to_fp32 to report an error when trying to access video memory. You need to switch to the CPU backend to run quantize.
After the fix, it will automatically run in the CPU backend and will no longer be bound to CUDA.
1 parent 3cd3a39 commit 6427ce9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

examples/llava/clip.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,9 +1370,9 @@ static ggml_cgraph * clip_image_build_graph(clip_ctx * ctx, const clip_image_f32
13701370
}
13711371

13721372
// read and create ggml_context containing the tensors and their data
1373-
struct clip_ctx * clip_model_load(const char * fname, const int verbosity = 1) {
1373+
struct clip_ctx * clip_model_load(const char * fname, const int verbosity, const bool use_gpu) {
13741374
return clip_init(fname, clip_context_params{
1375-
/* use_gpu */ true,
1375+
/* use_gpu */ use_gpu,
13761376
/* verbosity */ verbosity,
13771377
});
13781378
}
@@ -2989,7 +2989,7 @@ bool clip_model_quantize(const char * fname_inp, const char * fname_out, const i
29892989
assert(itype < GGML_TYPE_COUNT);
29902990
ggml_type type = static_cast<ggml_type>(itype);
29912991

2992-
auto * ctx_clip = clip_model_load(fname_inp, 2);
2992+
auto * ctx_clip = clip_model_load(fname_inp, 2, false);
29932993

29942994
const auto & ctx_src = ctx_clip->ctx_gguf;
29952995
const auto & ctx_data = ctx_clip->ctx_data;

examples/llava/clip.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct clip_context_params {
4545
};
4646

4747
// deprecated, use clip_init
48-
CLIP_API struct clip_ctx * clip_model_load(const char * fname, int verbosity);
48+
CLIP_API struct clip_ctx * clip_model_load(const char * fname, const int verbosity=1, const bool use_gpu=true);
4949

5050
CLIP_API struct clip_ctx * clip_init(const char * fname, struct clip_context_params ctx_params);
5151

0 commit comments

Comments
 (0)