49
41

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Raspberry Pi 4でBonsaiを動かしたよ

49
Posted at

こちらを見まして、二番煎じ記事でございます。

Bonsaiという新しいLLMで、1ビットモデルなんですって。

細かいことはよくわかりませんが、 Raspberry PiでLLMが動く というところに興味がありまして、やってみました。

環境

  • Raspberry Pi 4 (メモリ8GB)

2026/4/5時点の価格で33,110円ですって
最近のメモリ価格の高騰を受け、めっちゃ値上がりしれますね。

私はラズパイ4が出た頃に買ったのですが、確か、1万円ちょっとだった気がします。

llama.cppのビルド

Bonsaiの1ビットってのは、標準のllama.cppでは対応していないようで、カスタマイズ版が提供されています。

x64向けにはビルド済みのバイナリがReleaseに用意されているのですが、Raspberry Pi 4のようなarm64向けは存在しないので、ビルドします。

手順はこんな感じでした。

  1. ビルドに必要なものをインストール

    sudo apt update
    sudo apt install -y git cmake build-essential libopenblas-dev
    
  2. カスタマイズ版llama.cppのソースを取得

    git clone https://github.com/PrismML-Eng/llama.cpp
    cd llama.cpp
    
  3. ビルド

    cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
    cmake --build build --config Release -j2
    

モデルをダウンロード

Hugging Faceで公開されてるBonsaiをダウンロードします。HF_HUB_CACHEを指定することでダウンロード先を指定します。

HF_HUB_CACHE="$PWD/cache_hf" uvx hf download prism-ml/Bonsai-1.7B-gguf

実行

準備は整いましたので、実行しましょう。llama-cliを使います。

./build/bin/llama-cli \
  -m cache_hf/models--prism-ml--Bonsai-1.7B-gguf/snapshots/c89c1b5578286827264c4217f40edee617f4f904/Bonsai-1.7B.gguf 

image.png

起動しました!

Raspberry Piへは、Raspberry Pi Connectを使用して接続しています。
今回初めて使ってみたのですが、リモートアクセスが超絶やりやすいです!

一応動きますが、生成される内容は、まぁ、見なかったことにしましょう。日本のことを聞いた私が悪いのです。

3.3トークン/秒で生成できているようです。

image.png

実行中のtopコマンドの結果はこんな感じです。CPUはフル回転ですがメモリには余裕があります。

image.png

動画も用意しましたので、お時間ある方はご覧ください。遅いなりに、頑張ってる感があります。

49
41
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
49
41

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?