Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggml is compiled with cublas, but GPU is not used #106

Open
artur-ag opened this issue Nov 27, 2024 · 2 comments
Open

ggml is compiled with cublas, but GPU is not used #106

artur-ag opened this issue Nov 27, 2024 · 2 comments

Comments

@artur-ag
Copy link

I compiled ggml with -DGGML_CUBLAS=ON and then clip.cpp, and used it to get text encodings, but the GPU is not being used. The code takes the same amount of time as it did with CPU-only. Is this expected? Does clip_text_encode always use the CPU no matter what? Or did I forget to do something?

Details:
ggml is detecting the GPU without problem (Nvidia AGX Orin):

$ ./myapp
ggml_init_cublas: found 1 CUDA devices:
  Device 0: Orin, compute capability 8.7

Simplified version of my code:

#include "clip.h"
// ...
string model = "clip-vit-base-patch32_ggml-text-model-f16.gguf";
clip_ctx *ctx = clip_model_load(model.c_str(), verbosity);
for (int i = 0; i < 1000; i++)
  clip_tokenize(ctx, "person".c_str(), &tokens);
  float txt_vec[512];
  clip_text_encode(ctx, /*threads:*/4, &tokens, txt_vec, true);
}

This takes 8 seconds to finish. While this runs, I have jtop open, and I see the GPU is only active during the first 3 seconds, when ggml gets the GPU name and compute capability to print them. After that, the GPU goes offline. GPU usage is always 0%.

@monatis
Copy link
Owner

monatis commented Nov 27, 2024

Hi @artur-ag, I implemented clip.cpp back in the days when Convolution on CUDA was limited in GGML. Then, I implemented Cuda support for multimodal inference in llama.cpp, but I didn't backported it to clip.cpp.
I've just started working on llama.cpp-related projects again and one goal is also to modernize clip.cpp soon (I hope to announce new tools and libraries in one week or so, and modernized clip.cpp will follow them).

@artur-ag
Copy link
Author

Got it, thank you for the fast reply, and thank you for clip.cpp!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants