Skip to content

Raspberry Pi 4 4GB #58

Closed
Closed

Description

@miolini

Hi!

Just a report. I've successfully run the LLaMA 7B model on my 4GB RAM Raspberry Pi 4. It's super slow at about 10 sec/token. But it looks like we can run powerful cognitive pipelines on a cheap hardware. It's awesome. Thank you!

Hardware : BCM2835
Revision : c03111
Serial : 10000000d62b612e
Model : Raspberry Pi 4 Model B Rev 1.1

%Cpu0 : 71.8 us, 14.6 sy, 0.0 ni, 0.0 id, 2.9 wa, 0.0 hi, 10.7 si, 0.0 st
%Cpu1 : 77.4 us, 12.3 sy, 0.0 ni, 0.0 id, 10.4 wa, 0.0 hi, 0.0 si, 0.0 st
%Cpu2 : 81.0 us, 8.6 sy, 0.0 ni, 0.0 id, 10.5 wa, 0.0 hi, 0.0 si, 0.0 st
%Cpu3 : 77.1 us, 12.4 sy, 0.0 ni, 1.0 id, 9.5 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 3792.3 total, 76.2 free, 3622.9 used, 93.2 buff/cache
MiB Swap: 65536.0 total, 60286.5 free, 5249.5 used. 42.1 avail Mem

PID      USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND

2705518 ubuntu 20 0 5231516 3.3g 1904 R 339.6 88.3 84:16.70 main
102 root 20 0 0 0 0 S 14.2 0.0 29:54.42 kswapd0

main: seed = 1678644466
llama_model_load: loading model from './models/7B/ggml-model-q4_0.bin' - please wait ...
llama_model_load: n_vocab = 32000
llama_model_load: n_ctx = 512
llama_model_load: n_embd = 4096
llama_model_load: n_mult = 256
llama_model_load: n_head = 32
llama_model_load: n_layer = 32
llama_model_load: n_rot = 128
llama_model_load: f16 = 2
llama_model_load: n_ff = 11008
llama_model_load: n_parts = 1
llama_model_load: ggml ctx size = 4529.34 MB
llama_model_load: memory_size = 512.00 MB, n_mem = 16384
llama_model_load: loading model part 1/1 from './models/7B/ggml-model-q4_0.bin'
llama_model_load: .................................... done
llama_model_load: model size = 4017.27 MB / num tensors = 291

main: prompt: 'The first man on the moon was '
main: number of tokens in prompt = 9
1 -> ''
1576 -> 'The'
937 -> ' first'
767 -> ' man'
373 -> ' on'
278 -> ' the'
18786 -> ' moon'
471 -> ' was'
29871 -> ' '

sampling parameters: temp = 0.800000, top_k = 40, top_p = 0.950000, repeat_last_n = 64, repeat_penalty = 1.300000

The first man on the moon was 20 years old and looked^[ lot like me. In fact, when I read about Neil Armstrong during school lessons my fa

Activity

  1. miolini commented on Mar 12, 2023

    @miolini
    Author

    It looks it's possible to pack it to a AWS Lambda on ARM Gravitron + S3 weights offloading.

  2. neuhaus commented on Mar 12, 2023

    @neuhaus

    Is it swapping?
    Instead of opening new issues perhaps these numbers should be collected in issue #34 ("benchmarks?").

  3. miolini commented on Mar 12, 2023

    @miolini
    Author

    @neuhaus kswapd0 process is pretty active
    Screenshot 2023-03-12 at 12 23 28 PM

  4. dalnk commented on Mar 13, 2023

    @dalnk

    I'm trying to run it on a chromebook but I've hit a segfault :(
    image

    one thing I may have done wrong is that I reused the same .bin I created on my mac and it worked there.

  5. miolini commented on Mar 13, 2023

    @miolini
    Author

    @dalnk Do you have swap in the system?

  6. added
    documentation
    on Mar 13, 2023
  7. ekp1k80 commented on Mar 13, 2023

    @ekp1k80

    What do you change for be able to run it in the PI. i have a pc 4 times better and crash every i tried @miolini

  8. MarkSchmidty commented on Mar 13, 2023

    @MarkSchmidty

    llama.cpp on Samsung S22 Ultra at 1.2 tokens per second

    1.2 tokens/s on a Samsung S22 Ultra running 4 threads.

    The S22 obviously has a more powerful processor. But I do not think it is 12 times more powerful. It's likely you could get much faster speeds on the Pi.

    I'd be willing to bet that the bottleneck is not the processor.

  9. miolini commented on Mar 13, 2023

    @miolini
    Author

    @MarkSchmidty thank you for sharing your results. I believe my system swaped a lot due to limit size of RAM (4GB RAM, model size 4GB).

  10. MarkSchmidty commented on Mar 13, 2023

    @MarkSchmidty

    Ah, yes. A 3-bit implementation of 7B would fit fully in 4GB of RAM and lead to much greater speeds. This is the same issue as in #97.

    3-bit support is a proposed enhancement in GPTQ Quantization (3-bit and 4-bit) #9. GPTQ 3-bit has been shown to have negligible output quality vs uncompressed 16-bit and may even provide better output quality than the current naive 4-bit implementation in llama.cpp while requiring 25% less RAM.

  11. miolini commented on Mar 13, 2023

    @miolini
    Author

    @MarkSchmidty Fingers crossed!

  12. Ronsor commented on Mar 14, 2023

    @Ronsor
    Contributor

    I'm currently unable to build for aarch64 on an RPi 4 due to missing SIMD dot product intrinsics (vdotq_s32). Replacing them with abort() makes compilation complete but results in a crash at runtime. Changing -mcpu to include dotprod results in a runtime crash from an illegal instruction.

    ronsor@ronsor-rpi4:~/llama.cpp $ lscpu
    Architecture:                    aarch64
    CPU op-mode(s):                  32-bit, 64-bit
    Byte Order:                      Little Endian
    CPU(s):                          4
    On-line CPU(s) list:             0-3
    Thread(s) per core:              1
    Core(s) per socket:              4
    Socket(s):                       1
    Vendor ID:                       ARM
    Model:                           3
    Model name:                      Cortex-A72
    Stepping:                        r0p3
    CPU max MHz:                     2000.0000
    CPU min MHz:                     600.0000
    BogoMIPS:                        108.00
    L1d cache:                       128 KiB
    L1i cache:                       192 KiB
    L2 cache:                        1 MiB
    Vulnerability Itlb multihit:     Not affected
    Vulnerability L1tf:              Not affected
    Vulnerability Mds:               Not affected
    Vulnerability Meltdown:          Not affected
    Vulnerability Mmio stale data:   Not affected
    Vulnerability Retbleed:          Not affected
    Vulnerability Spec store bypass: Vulnerable
    Vulnerability Spectre v1:        Mitigation; __user pointer sanitization
    Vulnerability Spectre v2:        Vulnerable
    Vulnerability Srbds:             Not affected
    Vulnerability Tsx async abort:   Not affected
    Flags:                           fp asimd evtstrm crc32 cpuid```
    
  13. miolini commented on Mar 14, 2023

    @miolini
    Author

    @Ronsor Could you please share build log?

  14. Ronsor commented on Mar 14, 2023

    @Ronsor
    Contributor

    @Ronsor Could you please share build log?

    log.txt

  15. miolini commented on Mar 14, 2023

    @miolini
    Author

    @Ronsor something wrong with your environment.
    I UNAME_S: Linux
    I UNAME_P: unknown
    I UNAME_M: aarch64

    My build log on RPI starts with:
    I llama.cpp build info:
    I UNAME_S: Linux
    I UNAME_P: aarch64
    I UNAME_M: aarch64

  16. 39 remaining items

  17. added a commit that references this issue on May 9, 2026
    df13073
  18. added a commit that references this issue on May 11, 2026
    48cae02
  19. added a commit that references this issue on May 13, 2026
    c3e415a
  20. added a commit that references this issue on Jun 11, 2026
    a18afc8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbuild

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions