Spaces:
Runtime error
Runtime error
# Set up cache directories | |
export HF_HUB_CACHE=/tmp/huggingface | |
export TRANSFORMERS_CACHE=/tmp/transformers | |
export TORCH_HOME=/tmp/torch | |
# Clean up old cache files | |
echo "Cleaning up cache directories..." | |
rm -rf /tmp/huggingface/* /tmp/transformers/* /tmp/torch/* 2>/dev/null || true | |
# Clean up system temp files | |
echo "Cleaning up system temporary files..." | |
rm -rf /tmp/*.log /tmp/*.tmp /tmp/*.cache 2>/dev/null || true | |
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 .. | |
# Comprehensive cleanup before starting | |
echo "Performing comprehensive cleanup..." | |
# Clean Python cache 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 temporary files | |
find . -type f -name "*.tmp" -delete | |
find . -type f -name "*.temp" -delete | |
find . -type f -name "*.log" -delete | |
find . -type f -name "*.cache" -delete | |
# 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 | |
# Clean downloads directory if it exists | |
if [ -d "downloads" ]; then | |
echo "Cleaning downloads directory..." | |
find downloads -type f -mtime +1 -delete 2>/dev/null || true | |
fi | |
# Clean up any remaining temporary files in the current directory | |
rm -f *.log *.tmp *.temp 2>/dev/null || true | |
echo "Cleanup completed. Starting application..." | |
python app.py | |