GRDN.AI.3 / sitecustomize.py
danidanidani's picture
Add sitecustomize.py to fix OMP_NUM_THREADS at Python startup
f38a4b7
"""
This file runs automatically when Python starts, before any imports.
Used to fix HuggingFace Spaces OMP_NUM_THREADS issue.
"""
import os
# Fix OMP_NUM_THREADS before numexpr tries to use it
if 'OMP_NUM_THREADS' in os.environ:
value = str(os.environ['OMP_NUM_THREADS'])
if not value.isdigit():
os.environ['OMP_NUM_THREADS'] = '4'
print(f"Fixed OMP_NUM_THREADS from '{value}' to '4'")