quantize-my-repo / start.sh
mohanz's picture
use persistant storage for some of the library
615feff
raw
history blame
1.58 kB
#!/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