element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Sci-Pi Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Sci-Pi Design Challenge
  • More
  • Cancel
Sci-Pi Design Challenge
Blog Sci-Pi GPT - 2 Getting Started
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Sci-Pi Design Challenge to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: vlasov01
  • Date Created: 30 May 2023 2:32 AM Date Created
  • Views 1453 views
  • Likes 10 likes
  • Comments 1 comment
  • llm
  • alpaca
  • Ubuntu
  • sci-pi
  • swap
  • ai
  • raspberry pi 4 b
Related
Recommended

Sci-Pi GPT - 2 Getting Started

vlasov01
vlasov01
30 May 2023

Ubuntu

I've decided to try use Ubuntu as OS for my project. Here a re a few points for my decision:

  • I'm using it extensivly
  • It is officially support RPi4
  • Ubuntu is widly used by ML/AI community
  • It was referenced in one of the videos where a large language model (LLM) was successfully installed on RPi4 with 8GB of RAM
  • RPi Imager supports Ubuntu image creation
  • Ubuntu 22.04 comes with ZSWAP (RAM compression), which may help me to run LLM on 4GB RAM

Installation

It was easy to flash SD CARD using RPi Imager. But I've got stuck tryinhg to login as it didn't like my credentials. I'v flashed it again and I've used Ubuntu default userid/password this time. I've named my RPi host as scipi.

{gallery}Flashing Ubuntu 22.04 LTS on RPi 4B

Imager download page

IRPi Imager Download

Ubuntu 22.04 OS Selection

Ubuntu 22.04 64-bit selection

OS image settings

OS image settings

image flashing

Image flashing

image flashing completed

image flashing completed

Ubuntu 22.04 on RPi4

I've used a free Windows utilityAdvanced IP Scanner 2.5 to find the IP address of RPi on my network.

SciPi login

I've updated Ubuntu and created a swap to in preparation to testing LLM.

First Attempt to Run Alpaca LLM

I've followed an instruction on an LLM installation on RPi4B with 8GB of RAM shared at 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 . The author specifically mentioned that it will not work with 4GB of RAM. But as I've created extra 12 GB of swap I was hopping that it may work.

The instruction was very simple:

git clone https://github.com/antimatter15/alpaca.cpp 
cd alpaca.cpp 
make chat 
curl -o ggml-alpaca-7b-q4.bin -C - https://ipfs.io/ipfs/QmQ1bf2BTnYxq73MFJWu1B7bQ2UD6qG7D7YDCxhTndVkPC 
./chat

But the first challenge was to download the model. curl was not able to download the file. I've created a script to restart curl until the download completed.

But than I've got the Segmentation Fault error:

image

Than I've tried to adjust memory parameter with a few different values, but I've got the same issue:

image

It is possible that the model file was corrupted. But I was not sure if it has a checksum. And it seems that the program was validating the file too.

MPT-7B Model

I've looked for another models and found a new model from Mosaic. I've downloaded it and was able to run it on 4GB of RAM:

image

It was quite a slow process so.

The first test

I've asked a wrong question (mispelled Musk as Mask) and got a very imaginative answer. It took more than an hour for RPi 4 to generate it. Its 4 cores were not very busy at ~25% load. Most likely it was swapping memort back and forth. Next time I'll try to identify the bottleneck. I'll start with measuring the use of swap and zswap.

image

  • Sign in to reply
  • soldering.on
    soldering.on over 2 years ago

    Enjoyed reading Part 1 and 2 just now, thanks, it's an interesting project, I think we'd all love an AI personal assistant! Look forward to seeing where you take it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube