6

llama.cpp 開始支援 GPU 了

 1 year ago
source link: https://blog.gslin.org/archives/2023/05/15/11185/llama-cpp-%e9%96%8b%e5%a7%8b%e6%94%af%e6%8f%b4-gpu-%e4%ba%86/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

llama.cpp 開始支援 GPU 了

前陣子因為重灌桌機,所以在重建許多環境... 其中一個就是 llama.cpp,連到專案頁面上時意外發現這兩個新的 feature:

OpenBLAS support
cuBLAS and CLBlast support

這代表可以用 GPU 加速了,所以就照著說明試著編一個版本測試。

編好後就跑了 7B 的 model,看起來快不少,然後改跑 13B 的 model,也可以把完整 40 個 layer 都丟進 3060 (12GB 版本) 的 GPU 上:

./main -m models/13B/ggml-model-q4_0.bin -p "Building a website can be done in 10 simple steps:" -n 512 -ngl 40

從 log 可以看到 40 layers 到都 GPU 上面,吃了 7.5GB 左右:

llama.cpp: loading model from models/13B/ggml-model-q4_0.bin
llama_model_load_internal: format     = ggjt v2 (latest)
llama_model_load_internal: n_vocab    = 32000
llama_model_load_internal: n_ctx      = 512
llama_model_load_internal: n_embd     = 5120
llama_model_load_internal: n_mult     = 256
llama_model_load_internal: n_head     = 40
llama_model_load_internal: n_layer    = 40
llama_model_load_internal: n_rot      = 128
llama_model_load_internal: ftype      = 2 (mostly Q4_0)
llama_model_load_internal: n_ff       = 13824
llama_model_load_internal: n_parts    = 1
llama_model_load_internal: model size = 13B
llama_model_load_internal: ggml ctx size =  90.75 KB
llama_model_load_internal: mem required  = 9807.48 MB (+ 1608.00 MB per state)
llama_model_load_internal: [cublas] offloading 40 layers to GPU
llama_model_load_internal: [cublas] total VRAM used: 7562 MB
llama_init_from_file: kv self size  =  400.00 MB

30B 的 model 我也試著丟上去跑,但只能丟 28 layers 上去 (全部是 60 layers),再多 GPU 的記憶體就撐不住了。

但能用 GPU 算是一個很大的進展,現在這版只快了一半的時間,不知道後面還有沒有 tune 的空間...

Related

玩最近 Facebook Research (Meta) 放出來的 LLaMA

很多地方應該都有提到 Facebook Research (Meta) 放出來的 LLaMA 了,對應的論文是「LLaMA: Open and Efficient Foundation Language Models」這篇,但這邊論文提到的 open 並不是一般常見的 open 定義,而只是常見的行銷詞彙而已,實際上只是 free for charging with constraints。 另外要注意 LLaMA 是個 LLM 而已,跟 ChatGPT 不算是同樣性質的東西,能對比應該是 GPT-3 (或是 GPT-3.5)。 主要是 ChatGPT 多了 SL 與 RL 的步驟,而產出來的東西更接近商業化產品要的結果。 LLaMA 的特點在於效能不錯,可以用 LLaMA-13B 打贏 GPT-3 (175B),另外這次訓練出來最大的 LLaMA-65B 則可以站上第一梯隊 (與 DeepMind 的…

March 16, 2023

In "Computer"

這兩個禮拜爆紅的 Stable Diffusion

Stable Diffusion 是 Stability AI 訓練出來的 model,跟之前提到的 DALL-E 最大的差異就是產生出的圖的限制少很多: Unlike competing models like DALL-E, Stable Diffusion is open source and does not artificially limit the images it produces, though the license prohibits certain harmful use cases. 這也造就了這兩個禮拜整個 Stable Diffusion 的各種應用急速成長。 用 Simon Willison 的「Stable Diffusion is a really big deal」這篇來當作總覽還不錯。…

September 6, 2022

In "Computer"

用 GPU 跑 FFT

遲早會有人把腦筋動到 GPU 強大的運算能力上 :p 這次是利用 Nvidia 的 GPU 弄出一個數學函示庫 GPUFFTW,利用 GPU 計算 FFT 的基本運算加速:High performance FFT on GPUs。 在 Benchmark 中,透過 GPU 加速可以使得 FFT 整體的速度大約是純用 CPU 計算的四倍,但顯示卡的價錢卻只有 CPU 的 1/3。換句話說,把這類運算丟給 GPU 做,讓 CPU 計算其他的事情。 不過還是有些限制: 只有 32-bits (single-precision) float point 可以用,這是 GPU 所造成的限制,如果以後有 GPU 支援 64-bits 才有辦法支援上去。 只能跑 1-D FFT。…

May 30, 2006

In "Computer"

a611ee8db44c8d03a20edf0bf5a71d80?s=49&d=identicon&r=gAuthor Gea-Suan LinPosted on May 15, 2023Categories Computer, Murmuring, SoftwareTags blas, card, clblast, cpp, cublas, gpu, graphics, language, large, learning, llama, llama.cpp, llm, machine, model, nvidia, openblas, performance, speed, support, video

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment *

Name *

Email *

Website

Notify me of follow-up comments by email.

Notify me of new posts by email.

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Learn More)

Post navigation


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK