File size: 5,135 Bytes
5affea7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
chatgpt:=  https://chatgpt.com/share/69141b4b-3448-800e-87ef-fb83c51228e9

https://chatgpt.com/share/69141b4b-3448-800e-87ef-fb83c51228e9





Tutorial: How to Edit Run.bat for Llama.cpp Local Server

Step 1: Locate the Run.bat File

Go to the folder where you downloaded Llama.cpp.

Example path:


D:\Flie\llama.cpp

You will see Run.bat inside this folder.


Step 2: Open Run.bat for Editing

Right-click Run.bat → Choose Edit or Open with Notepad.

This will open the batch file and you can see the code inside.


Step 3: Edit the Base Directory

Look for the line that defines the BASE_DIR.

Example:


SET BASE_DIR=D:\Flie\llama.cpp

Replace D:\Flie\llama.cpp with your own Llama.cpp folder location if it’s different.


Step 4: Check Models Folder

Make sure you have a models folder inside your base folder.

Place all your .gguf model files inside this folder.

The batch file line should look like:


SET MODELS_DIR=%BASE_DIR%\models

Step 5: Save the File

After editing the path, click File → Save in Notepad.

Close Notepad.


Step 6: Run the File

Double-click Run.bat.

You will see a list of models with numbers.

Type the number of the model you want to run and press Enter.

The server will start and automatically open the browser at:


http://127.0.0.1:8080/


---

Step 7: Optional GPU/CPU Settings

The batch file uses GPU by default:


--n-gpu-layers 999

If you want CPU only, edit the line in Run.bat like this:


--n-gpu-layers 0


---

✅ Now your Run.bat is ready and will always show your models and run the server correctly.


---

ٹیوٹوریل: Run.bat کو ایڈٹ کرنا اور ماڈل فولڈر لوکیشن دینا (اردو)

Step 1: Run.bat فائل تلاش کریں

وہ فولڈر کھولیں جہاں آپ نے Llama.cpp رکھا ہوا ہے۔

مثال:


D:\Flie\llama.cpp

یہاں آپ کو Run.bat نظر آئے گا۔


Step 2: Run.bat کھولیں

Run.bat پر Right-click → Edit یا Open with Notepad کریں۔

Notepad میں فائل کھل جائے گی اور آپ کو کوڈ نظر آئے گا۔


Step 3: Base Directory ایڈٹ کریں

وہ لائن تلاش کریں جو BASE_DIR define کرتی ہے۔

مثال:


SET BASE_DIR=D:\Flie\llama.cpp

اگر آپ نے Llama.cpp کسی اور فولڈر میں رکھا ہے تو اس کا path یہاں دیں۔


Step 4: Models فولڈر چیک کریں

یقین کریں کہ base folder میں models فولڈر موجود ہے۔

اپنے تمام .gguf ماڈلز اس میں رکھیں۔

Batch فائل میں یہ لائن اس طرح ہونی چاہیے:


SET MODELS_DIR=%BASE_DIR%\models

Step 5: فائل Save کریں

Notepad میں File → Save کریں۔

Notepad بند کر دیں۔


Step 6: Run کریں

Run.bat پر Double-click کریں۔

ماڈلز کی لسٹ نمبر کے ساتھ دکھائی دے گی۔

جس ماڈل کو چلانا ہے اس کا نمبر لکھیں اور Enter دبائیں۔

Server start ہو جائے گا اور browser خود بخود کھلے گا:


http://127.0.0.1:8080/


---

Step 7: GPU یا CPU موڈ

Default GPU استعمال ہوتا ہے:


--n-gpu-layers 999

اگر CPU پر چلانا ہو تو 0 لکھیں:


--n-gpu-layers 0


---

✅ اب آپ کا Run.bat بالکل تیار ہے۔
یہ ہمیشہ ماڈل لسٹ دکھائے گا اور server صحیح طریقے سے چلائے گا۔























run.bat




@echo off
Title 🦙 Llama.cpp Local Server - GPU + Model Selector + Auto Chrome

REM --- PATH SETTINGS ---
SET BASE_DIR=D:\Flie\llama.cpp
SET MODELS_DIR=%BASE_DIR%\models
SET SERVER_EXE=%BASE_DIR%\llama-server.exe

REM --- SERVER SETTINGS ---
SET HOST_IP=0.0.0.0
SET PORT=8080
SET GPU_LAYERS=999
SET CONTEXT_SIZE=4096

echo ============================================
echo   🦙 Llama.cpp Local Server - Model Selector
echo ============================================
echo.
echo Available Models in: %MODELS_DIR%
echo.

REM --- LIST ALL MODELS ---
SETLOCAL ENABLEDELAYEDEXPANSION
SET COUNT=0
for %%f in ("%MODELS_DIR%\*.gguf") do (
    SET /A COUNT+=1
    echo !COUNT!. %%~nxf
    SET "MODEL[!COUNT!]=%%~nxf"
)

echo.
set /p choice=Enter the model number to load: 

IF "%choice%"=="" (
    echo No selection made. Exiting...
    pause
    exit /b
)

SET SELECTED_MODEL=!MODEL[%choice%]!
echo.
echo ✅ Selected model: %SELECTED_MODEL%
echo ---------------------------------------------

SET MODEL_PATH="%MODELS_DIR%\%SELECTED_MODEL%"

echo Starting llama-server with %SELECTED_MODEL% on GPU...
echo.

REM --- START SERVER ---
start "" "%SERVER_EXE%" --n-gpu-layers %GPU_LAYERS% --ctx-size %CONTEXT_SIZE% --port %PORT% --host %HOST_IP% -m %MODEL_PATH%

REM --- OPEN CHROME AUTOMATICALLY ---
timeout /t 2 >nul
start "" chrome http://127.0.0.1:%PORT%/

echo.
echo 🦙 Server started. Browser should open automatically.
pause