Spaces:
Runtime error
Runtime error
File size: 1,576 Bytes
3eaaf3a 615feff a8e6d06 615feff a8e6d06 3eaaf3a 186d7c9 3eaaf3a 186d7c9 3eaaf3a e510c4e 5144b92 186d7c9 e88cde7 e510c4e a8e6d06 615feff a8e6d06 615feff 3eaaf3a |
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 |
#!/bin/bash
# Set up persistent cache directories
export HF_HOME=/data/.huggingface
export HF_HUB_CACHE=${HF_HOME}/hub
export TRANSFORMERS_CACHE=${HF_HOME}/transformers
export TORCH_HOME=${HF_HOME}/torch
export DATASETS_CACHE=${HF_HOME}/datasets
export DIFFUSERS_CACHE=${HF_HOME}/diffusers
# Create cache directories if they don't exist
mkdir -p ${HF_HOME} ${HF_HUB_CACHE} ${TRANSFORMERS_CACHE} ${TORCH_HOME} ${DATASETS_CACHE} ${DIFFUSERS_CACHE}
if [ ! -d "llama.cpp" ]; then
# only run in dev env
git clone https://github.com/ggerganov/llama.cpp
fi
export GGML_CUDA=OFF
if [[ -z "${RUN_LOCALLY}" ]]; then
# enable CUDA if NOT running locally
export GGML_CUDA=ON
fi
cd llama.cpp
cmake -B build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=${GGML_CUDA}
cmake --build build --config Release -j --target llama-quantize llama-gguf-split llama-imatrix
cp ./build/bin/llama-* .
rm -rf build
cd ..
# Clean only non-persistent temporary files
echo "Cleaning temporary files..."
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
find . -type f -name "*.pyd" -delete
find . -type d -name "__pycache__" -exec rm -r {} + 2>/dev/null || true
find . -type d -name ".pytest_cache" -exec rm -r {} + 2>/dev/null || true
find . -type d -name ".coverage" -exec rm -r {} + 2>/dev/null || true
# Clean build artifacts
find . -type d -name "build" -exec rm -r {} + 2>/dev/null || true
find . -type d -name "dist" -exec rm -r {} + 2>/dev/null || true
find . -type d -name "*.egg-info" -exec rm -r {} + 2>/dev/null || true
echo "Starting application..."
python app.py
|