Fix:OMP_NUM_THREADS error on HF Spaces
Browse files- entrypoint.sh +6 -0
- requirements.txt +1 -1
entrypoint.sh
CHANGED
|
@@ -4,6 +4,12 @@ set -e
|
|
| 4 |
# Collect arguments passed to the container (CMD)
|
| 5 |
args=("$@")
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# If HF_TOKEN is set, append it to the arguments
|
| 8 |
if [ -n "$HF_TOKEN" ]; then
|
| 9 |
args+=("--hub_token" "$HF_TOKEN")
|
|
|
|
| 4 |
# Collect arguments passed to the container (CMD)
|
| 5 |
args=("$@")
|
| 6 |
|
| 7 |
+
# Sanitize OMP_NUM_THREADS if it's not an integer (e.g. "3500m" from HF Spaces)
|
| 8 |
+
if ! [[ "$OMP_NUM_THREADS" =~ ^[0-9]+$ ]]; then
|
| 9 |
+
echo "WARNING: OMP_NUM_THREADS is '$OMP_NUM_THREADS', which is not an integer. Resetting to 1."
|
| 10 |
+
export OMP_NUM_THREADS=1
|
| 11 |
+
fi
|
| 12 |
+
|
| 13 |
# If HF_TOKEN is set, append it to the arguments
|
| 14 |
if [ -n "$HF_TOKEN" ]; then
|
| 15 |
args+=("--hub_token" "$HF_TOKEN")
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
numpy
|
| 2 |
torch
|
| 3 |
torchvision
|
| 4 |
matplotlib
|
|
|
|
| 1 |
+
numpy<2.0
|
| 2 |
torch
|
| 3 |
torchvision
|
| 4 |
matplotlib
|