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

Add a way to change the number of openblas threads in ggml #452

Closed
klosax opened this issue Aug 15, 2023 · 3 comments
Closed

Add a way to change the number of openblas threads in ggml #452

klosax opened this issue Aug 15, 2023 · 3 comments

Comments

@klosax
Copy link
Contributor

klosax commented Aug 15, 2023

Openblas defaults to the maximum available threads (not physical cores) which is usually not optimal. User code should be able to control this directly to get optimal performance.

The number of threads used by openblas can be changed using:

void goto_set_num_threads(int num_threads);
void openblas_set_num_threads(int num_threads);

https://github.com/xianyi/OpenBLAS#setting-the-number-of-threads-at-runtime

@slaren
Copy link
Collaborator

slaren commented Aug 15, 2023

This can also be configured with an environment variable, and ggml can use many different BLAS libraries, not only OpenBLAS. The goal in the long term is also to replace BLAS with our own matrix multiplication routines. Maybe we could add documentation about these environment variables rather than adding a temporary, library specific API?

@klosax
Copy link
Contributor Author

klosax commented Aug 15, 2023

Maybe we could add documentation about these environment variables rather than adding a temporary, library specific API?

The main problem is that openblas defaults to max available threads. If control by user-code is not desirable, then maybe set it to physical cores minus the threads ggml needs? Environment variables are not very friendly to end-users..

@klosax
Copy link
Contributor Author

klosax commented Aug 15, 2023

Closing this since OpenBLAS does not seem to give any benefit at all anymore.
ggerganov/llama.cpp#2372

@klosax klosax closed this as completed Aug 15, 2023
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