Spaces:
Running on Zero
Running on Zero
Fix: install llama-cpp-python at runtime instead of build time
Browse files
app.py
CHANGED
|
@@ -420,10 +420,17 @@ def _run_benchmark():
|
|
| 420 |
if _BENCHMARK_RESULTS:
|
| 421 |
return _BENCHMARK_RESULTS
|
| 422 |
|
|
|
|
| 423 |
try:
|
| 424 |
from llama_cpp import Llama
|
| 425 |
except ImportError:
|
| 426 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
|
| 428 |
os.makedirs(_BENCHMARK_CACHE, exist_ok=True)
|
| 429 |
results = []
|
|
|
|
| 420 |
if _BENCHMARK_RESULTS:
|
| 421 |
return _BENCHMARK_RESULTS
|
| 422 |
|
| 423 |
+
# Install llama-cpp-python at runtime (not in requirements to avoid build issues)
|
| 424 |
try:
|
| 425 |
from llama_cpp import Llama
|
| 426 |
except ImportError:
|
| 427 |
+
_log("Benchmark: installing llama-cpp-python...")
|
| 428 |
+
import subprocess
|
| 429 |
+
subprocess.check_call(
|
| 430 |
+
[sys.executable, "-m", "pip", "install", "llama-cpp-python>=0.4.0", "--only-binary=:all:"],
|
| 431 |
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
| 432 |
+
)
|
| 433 |
+
from llama_cpp import Llama
|
| 434 |
|
| 435 |
os.makedirs(_BENCHMARK_CACHE, exist_ok=True)
|
| 436 |
results = []
|