Skip to content

Commit 1b39a8a

Browse files
committed
tweaks and fixes to stability on win32+linux
1 parent f8a7980 commit 1b39a8a

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

capabilities/llamacpp/app.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,26 @@ def first(pred):
115115
sys.exit(1)
116116

117117

118+
PROGRESS_INTERVAL_MB = 5
119+
120+
121+
def _progress_reporter():
122+
last_mb = [0.0]
123+
def hook(chunks, block_size, total_size):
124+
if total_size <= 0:
125+
return
126+
downloaded = chunks * block_size
127+
mb = downloaded / (1024 ** 2)
128+
total_mb = total_size / (1024 ** 2)
129+
if mb - last_mb[0] >= PROGRESS_INTERVAL_MB or downloaded >= total_size:
130+
print(f' {mb:.1f} / {total_mb:.1f} MB', flush=True)
131+
last_mb[0] = mb
132+
return hook
133+
134+
118135
def download_file(url, dest):
119-
print(f'Downloading {os.path.basename(dest)} ...')
120-
urllib.request.urlretrieve(url, dest, reporthook=lambda c, bs, ts: print(f' {c*bs/(1024**2):.1f} MB', end='\r') if ts > 0 else None)
121-
print()
136+
print(f'Downloading {os.path.basename(dest)} ...', flush=True)
137+
urllib.request.urlretrieve(url, dest, reporthook=_progress_reporter())
122138

123139

124140
def extract(archive, dest_dir):

capabilities/llamacpp/pixi.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ depends-on = ["download-llamacpp"]
103103

104104
[feature.gpu.target.win-64.tasks.serve]
105105
args = [{ arg = "model", default = "unsloth/gemma-4-E4B-it-GGUF:Q4_K_M" }]
106-
cmd = """HF_HOME=models PATH="bin:$PATH" python serve.py \
106+
cmd = """HF_HOME=models PATH="bin;$PATH" python serve.py \
107107
--model "{{ model }}" \
108108
--backend gpu"""
109109
depends-on = ["download-llamacpp"]

capabilities/llamacpp/serve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def start_server(model, backend):
220220
def main():
221221
parser = argparse.ArgumentParser(description='Prepare model cache and launch llama.cpp server.')
222222
parser.add_argument('--model', default=DEFAULT_MODEL)
223-
parser.add_argument('--backend', choices=['cpu', 'gpu'], default=os.environ.get('LLAMA_BACKEND', 'cpu'))
223+
parser.add_argument('--backend', choices=['cpu', 'gpu'], default=os.environ.get('LLAMA_BACKEND', 'gpu'))
224224
args = parser.parse_args()
225225

226226
os.environ.setdefault('HF_HOME', HF_HOME)

0 commit comments

Comments
 (0)