-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Alternate OpenCL support via the CLBlast Netlib BLAS API #891
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Building with CLBlast speeds up whisper.cpp ~2x on low end / older AMD APUs (CPU with integrated GPU) such as the A9. Usage: WHISPER_CLBLAST=1 make
Building with CLBlast speeds up whisper.cpp ~2x on low end / older AMD APUs (CPU with integrated GPU) such as the A9. Usage: ``` Makefile: cd whisper.cpp WHISPER_CLBLAST=1 make CMake: cd whisper.cpp ; mkdir build ; cd build cmake -DWHISPER_CLBLAST=ON .. make ```
Added OpenCL Build Instructions
Added build instructions and examples for Make and CMake to support OpenCL enabled GPUs.
Experimental alternate OpenCL support via the CLBlast Netlib BLAS API. The performance is quite similar to the CLBlast optimized implementation when tested on the same low end / old AMD A9 APU. CLBlast needs to be compiled with ```-DNETLIB=ON``` flag. Rationale: Support More Hardware. This is meant to be used as a last resort for GPU acceleration when other methods don't work or are not compatible. Since OpenCL 1.x EMBEDDED PROFILE is supported, I anticipate that this could enable acceleration on Single Board Computers and Smart Phones. Also serves as a template for pre-emptive OpenCL support for projects that use ggml. This could provide baseline GPU acceleration without custom OpenCL code or added effort due to CLBlast being a drop in BLAS with the Netlib API enabled. More Info: https://github.com/CNugteren/CLBlast/blob/master/doc/bindings.md CNugteren/CLBlast#227 Usage: ``` Makefile: cd whisper.cpp WHISPER_CLBLAST_NETLIB=1 make CMake: cd whisper.cpp ; mkdir build ; cd build cmake -DWHISPER_CLBLAST_NETLIB=ON .. make ```
…tlib BLAS API Added build instructions and examples for the experimental alternate OpenCL support via the CLBlast Netlib BLAS API.
ggerganov
requested changes
May 8, 2023
ggml.c
Outdated
@@ -8187,7 +8189,7 @@ static void ggml_compute_forward_rms_norm( | |||
|
|||
// ggml_compute_forward_mul_mat | |||
|
|||
#if defined(GGML_USE_ACCELERATE) || defined(GGML_USE_OPENBLAS) || defined(GGML_USE_CLBLAST) | |||
#if defined(GGML_USE_ACCELERATE) || defined(GGML_USE_OPENBLAS) || defined(GGML_USE_CLBLAST) || defined(GGML_USE_CLBLASTNETLIB) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's have this build define both GGML_USE_CLBLAST
and GGML_USE_CLBLASTNETLIB
and avoid these changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct, I get the logic.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Experimental alternate OpenCL support via the CLBlast Netlib BLAS API. The performance is quite similar to the CLBlast optimized implementation when tested on the same low end / old AMD A9 APU.
CLBlast needs to be compiled with
-DNETLIB=ON
flag.Rationale: Support More Hardware. This is meant to be used as a last resort for GPU acceleration when other methods don't work or are not compatible. Since OpenCL 1.x EMBEDDED PROFILE is supported, I anticipate that this could enable acceleration on Single Board Computers and Smart Phones.
Also serves as a template for pre-emptive OpenCL support for projects that use ggml. This could provide baseline GPU acceleration without custom OpenCL code or added effort due to CLBlast being a drop in BLAS with the Netlib API enabled.
More Info:
https://github.com/CNugteren/CLBlast/blob/master/doc/bindings.md
CNugteren/CLBlast#227
Usage:
Benchmarks:
Standard:
With CLBlast:
With CLBlast Netlib API:
Currently, CLBlast with Netlib API seems to have a advantage over CLBlast and custom OpenCL code:
The load time is higher with CLBlast and custom OpenCL code. This is emphasized when using the tiny model. This has the effect that the net performance seems to be equal or better:
Command: ./bench -m models/ggml-tiny.en.bin
CLBlast Netlib:
CLBlast: