LesionDetection / entrypoint.sh
maregu2023's picture
fix: sanitize OMP_NUM_THREADS at 3 levels to prevent libgomp crash on HF Spaces
8d0d76d
raw
history blame contribute delete
954 Bytes
#!/bin/bash
# =============================================================================
# Entrypoint for HF Spaces Docker container
# Sanitizes environment variables before starting the application
# =============================================================================
# Fix: HF Spaces Kubernetes injects OMP_NUM_THREADS=3500m (millicores string)
# which libgomp/OpenMP cannot parse. Force valid integer values.
export OMP_NUM_THREADS=4
export MKL_NUM_THREADS=4
export OPENBLAS_NUM_THREADS=4
export NUMEXPR_NUM_THREADS=4
echo "===== Application Startup at $(date '+%Y-%m-%d %H:%M:%S') ====="
echo "OMP_NUM_THREADS=$OMP_NUM_THREADS"
echo "Python: $(python --version)"
echo "PyTorch: $(python -c 'import torch; print(torch.__version__)' 2>/dev/null || echo 'N/A')"
echo "CUDA available: $(python -c 'import torch; print(torch.cuda.is_available())' 2>/dev/null || echo 'N/A')"
exec uvicorn seg_app.backend.api:app --host 0.0.0.0 --port 7860