CherithCutestory commited on
Commit
126d204
·
1 Parent(s): 4764a70

Tweaked the num threads env var setting code to handle weird edge cases.

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -1,7 +1,12 @@
1
  import os, sys, subprocess
2
 
3
- # Fix the OpenMP warning (Spaces sometimes sets this to a non-integer)
4
- os.environ["OMP_NUM_THREADS"] = str(int(os.environ.get("OMP_NUM_THREADS", "1") or "1"))
 
 
 
 
 
5
 
6
  def ensure_styletts2():
7
  try:
 
1
  import os, sys, subprocess
2
 
3
+ # ---- Fix OpenMP env issue on HF ----
4
+ val = os.environ.get("OMP_NUM_THREADS", "1")
5
+ try:
6
+ val = str(int(val))
7
+ except Exception:
8
+ val = "1"
9
+ os.environ["OMP_NUM_THREADS"] = val
10
 
11
  def ensure_styletts2():
12
  try: