Spaces:
Running on Zero
Running on Zero
Upload app/main.py with huggingface_hub
Browse files- app/main.py +6 -3
app/main.py
CHANGED
|
@@ -11,9 +11,12 @@ import urllib.request
|
|
| 11 |
from contextlib import asynccontextmanager
|
| 12 |
|
| 13 |
import torch
|
| 14 |
-
# Restrict PyTorch thread-pool memory
|
| 15 |
-
|
| 16 |
-
torch.
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
from fastapi import FastAPI
|
| 19 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
| 11 |
from contextlib import asynccontextmanager
|
| 12 |
|
| 13 |
import torch
|
| 14 |
+
# Restrict PyTorch thread-pool memory if possible
|
| 15 |
+
try:
|
| 16 |
+
torch.set_num_threads(1)
|
| 17 |
+
torch.set_num_interop_threads(1)
|
| 18 |
+
except (RuntimeError, ValueError):
|
| 19 |
+
pass
|
| 20 |
|
| 21 |
from fastapi import FastAPI
|
| 22 |
from fastapi.middleware.cors import CORSMiddleware
|