Spaces:
Runtime error
Runtime error
J.B-Lin commited on
Commit ·
12a8a38
1
Parent(s): 1a07461
chore: add build_llama_server.sh (local cross-compile script, unused)
Browse files
modal_deploy/build_llama_server.sh
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Build llama-server locally for linux/amd64 (Modal's target)
|
| 3 |
+
# Uses Docker to cross-compile, then uploads binary to Modal Volume
|
| 4 |
+
|
| 5 |
+
set -e
|
| 6 |
+
|
| 7 |
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
| 8 |
+
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
| 9 |
+
LLAMACPP_DIR="$SCRIPT_DIR/llamacpp_omni"
|
| 10 |
+
OUTPUT_DIR="$SCRIPT_DIR/build_output"
|
| 11 |
+
|
| 12 |
+
echo "=== PregoPal: Cross-build llama-server for Modal ==="
|
| 13 |
+
echo "Source: $LLAMACPP_DIR"
|
| 14 |
+
echo "Output: $OUTPUT_DIR"
|
| 15 |
+
|
| 16 |
+
# Clean output
|
| 17 |
+
rm -rf "$OUTPUT_DIR"
|
| 18 |
+
mkdir -p "$OUTPUT_DIR"
|
| 19 |
+
|
| 20 |
+
# Build with docker using linux/amd64 (Modal's arch)
|
| 21 |
+
docker run --rm \
|
| 22 |
+
-v "$LLAMACPP_DIR:/llama.cpp-omni" \
|
| 23 |
+
-v "$OUTPUT_DIR:/output" \
|
| 24 |
+
-w /llama.cpp-omni \
|
| 25 |
+
--platform linux/amd64 \
|
| 26 |
+
nvidia/cuda:12.4.1-devel-ubuntu22.04 \
|
| 27 |
+
bash -c "
|
| 28 |
+
apt-get update && apt-get install -y cmake build-essential libcurl4-openssl-dev pkg-config &&
|
| 29 |
+
cmake -B build \
|
| 30 |
+
-DGGML_CUDA=ON \
|
| 31 |
+
-DLLAMA_BUILD_SERVER=ON \
|
| 32 |
+
-DLLAMA_BUILD_TESTS=OFF \
|
| 33 |
+
-DLLAMA_BUILD_EXAMPLES=OFF \
|
| 34 |
+
-DLLAMA_CUDA_FORCE_MMQ=ON \
|
| 35 |
+
-DCMAKE_CUDA_ARCHITECTURES='75;89' \
|
| 36 |
+
-DCMAKE_BUILD_TYPE=Release &&
|
| 37 |
+
cmake --build build --config Release -j \$(nproc) --target llama-server &&
|
| 38 |
+
cp build/bin/llama-server /output/
|
| 39 |
+
"
|
| 40 |
+
|
| 41 |
+
echo "=== Build complete! Binary: $OUTPUT_DIR/llama-server ==="
|
| 42 |
+
ls -lh "$OUTPUT_DIR/llama-server"
|
| 43 |
+
file "$OUTPUT_DIR/llama-server"
|