Standalone, Binary Portable, Bootable Llama 2
This is a Unikraft-centric setup of Llama 2 Everywhere (L2E). It exposes a very basic HTTP service that can be queried to provide a reply from Llama 2.
For a quick setup, run the commands below. Note that you still need to install the requirements.
For building and running everything for x86_64, follow the steps below:
git clone https://github.com/unikraft/app-llama2-c llama2-c
cd llama2-c/
./scripts/setup.sh
wget https://raw.githubusercontent.com/unikraft/app-testing/staging/scripts/generate.py -O scripts/generate.py
chmod a+x scripts/generate.py
./scripts/generate.py
./scripts/build/make-qemu-x86_64.sh
./scripts/run/qemu-x86_64.shThis will configure, build and run the L2E service.
It listens for connections on port 8080 of address 172.44.0.2.
Open another console to query the service and get a story:
curl 172.44.0.2:8080In order to set up, configure, build and run L2E on Unikraft, the following packages are required:
build-essential/base-devel/@development-tools(the meta-package that includesmake,gccand other development-related packages)sudoflexbisongitwgetuuid-runtimeqemu-system-x86qemu-system-armqemu-kvmsgabiosgcc-aarch64-linux-gnu
GCC >= 8 is required to build L2E on Unikraft.
On Ubuntu/Debian or other apt-based distributions, run the following command to install the requirements:
sudo apt install -y --no-install-recommends \
  build-essential \
  sudo \
  gcc-aarch64-linux-gnu \
  libncurses-dev \
  libyaml-dev \
  flex \
  bison \
  git \
  wget \
  uuid-runtime \
  qemu-kvm \
  qemu-system-x86 \
  qemu-system-arm \
  sgabiosThe following repositories are required for L2E:
- The application repository (this repository): 
app-llama2-c - The Unikraft core repository: 
unikraft - Library repositories:
- The Musl libc library: 
lib-musl 
 - The Musl libc library: 
 
Follow the steps below for the setup:
- 
First clone the
app-llama2-crepository in thellama2-c/directory:git clone https://github.com/unikraft/app-llama2-c llama-cEnter the
llama2-c/directory:cd llama2-c/ ls -F
This will print the contents of the repository:
defconfigs/ LICENSE Makefile Makefile.uk README.md run.c scripts/ strliteral.c tokenizer.bin - 
While inside the
llama-2/directory, use thescripts/setup.shto set repositories and required files:./scripts/setup.shIt will download required model files and it will clone the repositories in the workdir directory:
workdir/ |-- libs/ | `-- musl/ `-- unikraft/ |-- ADOPTERS.md |-- arch/ |-- Config.uk |-- CONTRIBUTING.md |-- COPYING.md |-- drivers/ |-- include/ |-- lib/ |-- Makefile |-- Makefile.uk |-- plat/ |-- README.md |-- support/ `-- version.mk 
To build and run Unikraft images, it's easiest to generate build and running scripts and use those.
First of all, grab the generate.py script and place it in the scripts/ directory by running:
wget https://raw.githubusercontent.com/unikraft/app-testing/staging/scripts/generate.py -O scripts/generate.py
chmod a+x scripts/generate.pyNow, run the generate.py script.
You must run it in the root directory of this repository:
./scripts/generate.pyRunning the script will generate build and run scripts in the scripts/build/ and the scripts/run/ directories:
scripts/
|-- build/
|   |-- kraft-fc-arm64.sh*
|   |-- kraft-fc-x86_64.sh*
|   |-- kraft-qemu-arm64.sh*
|   |-- kraft-qemu-x86_64.sh*
|   |-- make-fc-x86_64.sh*
|   `-- make-qemu-x86_64.sh*
|-- generate.py*
|-- run/
|   |-- fc-x86_64.json
|   |-- fc-x86_64.sh*
|   |-- kraft-fc-arm64.sh*
|   |-- kraft-fc-x86_64.sh*
|   |-- kraft-qemu-arm64.sh*
|   |-- kraft-qemu-x86_64.sh*
|   `-- qemu-x86_64.sh*
|-- run.yaml
`-- setup.sh*
You can now build and run images for different configurations.
For example, to build and run for QEMU on x86_64, run:
./scripts/build/make-qemu-x86_64.sh
./scripts/run/qemu-x86_64.shThis will
To build and run for Firecracker on x86_64 using KraftKit, run:
./scripts/build/kraft-fc-x86_64.sh
./scripts/run/kraft-fc-x86_64.shThe run script will start the L2E service.
It listens for connections on port 8080 of address 172.44.0.2.
Open another console to query the service and get a story:
curl 172.44.0.2:8080Close the QEMU instance by using the Ctrl+a x keyboard combination.
That is, press Ctrl and a simultaneously, then release and press x.
For Firecracker, you would have to kill the process by issuing a command. Simplest is to open up another console and run:
pkill -f firecrackerNote that Firecracker networking support is not yet enabled, so that will not work.