Spaces:
Runtime error
Runtime error
Peter Michael Gits Claude commited on
Commit ·
9201e6d
1
Parent(s): dd577b3
Fix OMP_NUM_THREADS being overridden by HuggingFace CPU_CORES
Browse filesv1.4.1 - CRITICAL FIX: HuggingFace overriding OMP_NUM_THREADS with CPU_CORES
- App was exiting because OMP_NUM_THREADS='3500m' instead of '1'
- HuggingFace environment was overriding our Dockerfile ENV
- Added explicit Python os.environ override BEFORE torch imports
- This should prevent app crashes and libgomp errors
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
app.py
CHANGED
|
@@ -6,8 +6,13 @@ import os
|
|
| 6 |
from typing import Optional
|
| 7 |
from contextlib import asynccontextmanager
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
import torch
|
| 13 |
import numpy as np
|
|
@@ -16,7 +21,7 @@ from fastapi.responses import JSONResponse, HTMLResponse
|
|
| 16 |
import uvicorn
|
| 17 |
|
| 18 |
# Version tracking
|
| 19 |
-
VERSION = "1.4.
|
| 20 |
COMMIT_SHA = "TBD"
|
| 21 |
|
| 22 |
# Configure logging
|
|
|
|
| 6 |
from typing import Optional
|
| 7 |
from contextlib import asynccontextmanager
|
| 8 |
|
| 9 |
+
# CRITICAL: Set OMP_NUM_THREADS before any torch/numpy imports
|
| 10 |
+
# HuggingFace is overriding our Dockerfile ENV with CPU_CORES value
|
| 11 |
+
os.environ['OMP_NUM_THREADS'] = '1'
|
| 12 |
+
# Also ensure other environment variables are correct
|
| 13 |
+
os.environ['HF_HOME'] = '/app/hf_cache'
|
| 14 |
+
os.environ['HUGGINGFACE_HUB_CACHE'] = '/app/hf_cache'
|
| 15 |
+
os.environ['TRANSFORMERS_CACHE'] = '/app/hf_cache'
|
| 16 |
|
| 17 |
import torch
|
| 18 |
import numpy as np
|
|
|
|
| 21 |
import uvicorn
|
| 22 |
|
| 23 |
# Version tracking
|
| 24 |
+
VERSION = "1.4.1"
|
| 25 |
COMMIT_SHA = "TBD"
|
| 26 |
|
| 27 |
# Configure logging
|