You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/embedded-and-microcontrollers/rpi-llama3/llama3.md
+23-59Lines changed: 23 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,52 +23,21 @@ The next steps explain how to compile and run the Llama 3 model.
23
23
24
24
## Download and export the Llama 3 8B model
25
25
26
-
To get started with Llama 3, you can obtain the pre-trained parameters by visiting [Meta's Llama Downloads](https://llama.meta.com/llama-downloads/) page.
26
+
To get started with Llama 3, you can obtain the pre-trained parameters by visiting [Meta's Llama Downloads](https://llama.meta.com/llama-downloads/) page.
27
27
28
28
Request access by filling out your details, and read through and accept the Responsible Use Guide. This grants you a license and a download link that is valid for 24 hours. The Llama 3 8B model is used for this part, but the same instructions apply for other models.
29
29
30
-
Clone the Llama 3 Git repository and install the dependencies:
30
+
Use the `llama-stack` library to download the model after having the license granted.
llama model download --source meta --model-id meta-llama/Llama-3.1-8B
37
35
```
38
36
39
-
Run the script to download, and paste the download link from the email when prompted:
40
-
41
-
```bash
42
-
cd models/llama3_1
43
-
./download.sh
44
-
```
45
-
46
-
You are asked which models you would like to download. Enter `meta-llama-3.1-8b` to get the model used for this Learning Path:
47
-
48
-
```output
49
-
**** Model list ***
50
-
- meta-llama-3.1-405b
51
-
- meta-llama-3.1-70b
52
-
- meta-llama-3.1-8b
53
-
- meta-llama-guard-3-8b
54
-
- prompt-guard
55
-
```
56
-
57
-
After entering `meta-llama-3.1-8b` you are prompted again with the available models:
58
-
59
-
```output
60
-
**** Available models to download: ***
61
-
- meta-llama-3.1-8b-instruct
62
-
- meta-llama-3.1-8b
63
-
Enter the list of models to download without spaces or press Enter for all:
64
-
```
65
-
66
-
Enter `meta-llama-3.1-8b` to start the download.
67
-
68
37
When the download is finished, you can list the files in the new directory:
69
38
70
39
```bash
71
-
ls Meta-Llama-3.1-8B
40
+
ls /home/pi/.llama/checkpoints/Llama3.1-8B
72
41
```
73
42
74
43
The output is:
@@ -85,34 +54,26 @@ If you encounter the error "Sorry, we could not process your request at this mom
85
54
86
55
The next step is to generate a `.pte` file that can be used for prompts. From the `executorch` directory, compile the model executable. Note the quantization option, which reduces the model size significantly.
87
56
88
-
If you've followed the tutorial, this should now take you to the `executorch` base directory.
89
-
90
-
Navigate back to the top-level directory of the `executorch` repository:
91
-
92
-
```bash {cwd="executorch"}
93
-
cd ../../../
94
-
```
95
-
96
-
You are now in `$HOME/executorch` and ready to create the model file for ExecuTorch.
57
+
If you've followed the tutorial, you should be in the `executorch` base directory.
97
58
98
-
Run the Python command below to create the model file, `llama3_kv_sdpa_xnn_qe_4_32.pte`.
59
+
Run the Python command below to create the model file, `llama3_kv_sdpa_xnn_qe_4_32.pte`.
--prompt="Write a python script that prints the first 15 numbers in the Fibonacci series. Annotate the script with comments explaining what the code does."
163
127
```
164
128
165
-
You can use `cmake-out/examples/models/llama2/llama_main --help` to read about the options.
129
+
You can use `cmake-out/examples/models/llama2/llama_main --help` to read about the options.
166
130
167
131
If all goes well, you will see the model output along with some memory statistics. Some output has been omitted for better readability.
168
132
@@ -185,5 +149,5 @@ I 00:00:46.844400 executorch:runner.cpp:134] append_eos_to_prompt: 0
185
149
186
150
You now know how to run a Llama model in Raspberry Pi OS using ExecuTorch. You can experiment with different prompts and different numbers of CPU threads.
187
151
188
-
If you have access to the RPi 5, continue to the next section to see how to deploy the software to the board and run it.
152
+
If you have access to the RPi 5, continue to the next section to see how to deploy the software to the board and run it.
Copy file name to clipboardExpand all lines: content/learning-paths/embedded-and-microcontrollers/rpi-llama3/run.md
+15-16Lines changed: 15 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ This final section explains how to test the model by experimenting with differen
9
9
10
10
## Set up your Raspberry Pi 5
11
11
12
-
If you want to see how the LLM behaves in an embedded environment, you need a Raspberry Pi 5 running Raspberry Pi OS.
12
+
If you want to see how the LLM behaves in an embedded environment, you need a Raspberry Pi 5 running Raspberry Pi OS.
13
13
14
14
Install Raspberry Pi OS using the [Raspberry Pi documentation](https://www.raspberrypi.com/documentation/computers/getting-started.html). There are numerous ways to prepare an SD card, but Raspberry Pi recommends [Raspberry Pi Imager](https://www.raspberrypi.com/software/) on a Windows, Linux, or macOS computer with an SD card slot or SD card adapter.
15
15
@@ -19,22 +19,21 @@ The 8GB RAM Raspberry Pi 5 model is preferred for exploring an LLM.
19
19
20
20
## Collect the files into an archive
21
21
22
-
There are just a few files that you need to transfer to the Raspberry Pi 5. You can bundle them together and transfer them from the running container to the development machine, and then to the Raspberry Pi 5.
22
+
There are just a few files that you need to transfer to the Raspberry Pi 5. You can bundle them together and transfer them from the running container to the development machine, and then to the Raspberry Pi 5.
23
23
24
-
You should still be in the container, in the `$HOME/executorch` directory.
24
+
You should still be in the container, in the `$HOME/executorch` directory.
25
25
26
26
The commands below copy the needed files to a new directory. The model file is very large and takes time to copy.
Compress the files into an archive using the `tar` command:
@@ -45,7 +44,7 @@ tar czvf llama3-files.tar.gz ./llama3-files
45
44
46
45
Next, copy the compressed tar file out of the container to the development computer. This is done using the `docker cp` command from the development machine.
47
46
48
-
Open a new shell or terminal on the development machine where Docker is running the container.
47
+
Open a new shell or terminal on the development machine where Docker is running the container.
49
48
50
49
Find the `CONTAINER ID` for the running container:
51
50
@@ -60,7 +59,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAME
60
59
88c34c899c8c rpi-os "/bin/bash" 7 hours ago Up 7 hours fervent_vaughan
61
60
```
62
61
63
-
Your `CONTAINER ID` will be different so substitute your value.
62
+
Your `CONTAINER ID` will be different so substitute your value.
0 commit comments