File size: 412 Bytes
f38a4b7
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
"""
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'")