1- # Hands-on Guide: Setting Up Qwen 2.1 on AWS EC2 with Ollama
1+ # Hands-on Guide: Setting Up LLMs on AWS EC2 with Ollama
22
3- This guide walks you through setting up and running Qwen 2.1, a small but efficient LLM , on a free tier AWS EC2 instance using Ollama.
3+ This guide walks you through setting up and running SmolLm2 or Qwen 2.1, small but efficient LLMs , on a free tier AWS EC2 instance using Ollama.
44
5- ## 1. Creating an EC2 Instance
5+ ## 1. Create an EC2 Instance.
66
771 . ** Log in to AWS Console**
88 - Go to https://aws.amazon.com/console/
@@ -35,7 +35,7 @@ This guide walks you through setting up and running Qwen 2.1, a small but effici
3535 5 . - ** Configure Storage** : 30GB gp3 (free tier maximum, 30GB+ recommended)
3636 - Click "Launch Instance"
3737
38- ## 2. Connecting to Your Instance
38+ ## 2. Connect to Your Instance
3939
40401 . ** Find your instance public IP**
4141 - On EC2 dashboard, select your instance
@@ -49,7 +49,7 @@ This guide walks you through setting up and running Qwen 2.1, a small but effici
4949 ```
5050 - On Windows, use PuTTY or Windows Terminal
5151
52- # # 3. Create swap space (8GB recommended)
52+ # # 3. Create swap space (8GB recommended on free tier )
5353
5454` ` ` bash
5555 sudo fallocate -l 8G /swapfile
@@ -58,7 +58,7 @@ This guide walks you through setting up and running Qwen 2.1, a small but effici
5858 sudo swapon /swapfile
5959` ` `
6060
61- # # 4. Installing Ollama
61+ # # 4. Install Ollama
6262
6363** Install Ollama**
6464 ` ` ` bash
@@ -73,7 +73,7 @@ This guide walks you through setting up and running Qwen 2.1, a small but effici
7373! [Install Ollama](https://raw.githubusercontent.com/kaizengrowth/oklahomai/main/assets/images/step4.png)
7474
7575
76- # # 5. Setting Up and Running a Small LLM
76+ # # 5. Set Up and Running a Small LLM
7777
7878** Pull and run the smallest smollm2 model**
7979` ` ` bash
@@ -87,10 +87,22 @@ Test the model with a prompt!
8787 ollama pull qwen2:0.5b
8888 ollama run qwen2:0.5b
8989 ` ` `
90- Test the model with a prompt!
9190
91+ # # 6. Clean Up
92+
93+ When you' re done, remember to stop or terminate your EC2 instance to avoid unnecessary charges:
94+
95+ 1. In the EC2 dashboard, select your instance
96+ 2. Choose "Instance state" and select "Stop" or "Terminate"
97+
98+ **Note**: Stopping the instance will preserve your data but still incur storage costs. Terminating the instance will delete all data.
99+
100+ ----
101+
102+
103+ # Alternatives
92104
93- # # 6. Running Ollama as a Service
105+ ## A. Run Ollama as a Service
94106
951071. **Start Ollama service**
96108 ```bash
@@ -107,7 +119,7 @@ Test the model with a prompt!
107119 sudo systemctl status ollama
108120 ```
109121
110- # # 7. Using the Ollama API
122+ ## B. Use the Ollama API
111123
112124Ollama provides a REST API that you can use for more advanced usage:
113125
@@ -124,21 +136,11 @@ Ollama provides a REST API that you can use for more advanced usage:
124136 ```bash
125137 curl http://localhost:11434/api/tags
126138 ```
127- ```
128139
129- ## 8. Running Ollama in the Background
140+ ## C. Run Ollama in the Background
130141
131142If you want to keep Ollama running after disconnecting:
132143
133144```bash
134145nohup ollama serve > ollama.log 2>&1 &
135- ```
136-
137- ## 9. Cleaning Up
138-
139- When you're done, remember to stop or terminate your EC2 instance to avoid unnecessary charges:
140-
141- 1 . In the EC2 dashboard, select your instance
142- 2 . Choose "Instance state" and select "Stop" or "Terminate"
143-
144- ** Note** : Stopping the instance will preserve your data but still incur storage costs. Terminating the instance will delete all data.
146+ ```
0 commit comments