Spaces:
Sleeping
Sleeping
File size: 906 Bytes
a42d9ad | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | """Configure the Tensor Pruning API for a single Docker Space replica."""
import os
from pathlib import Path
from fastapi.responses import RedirectResponse
from tensor_pruning.service import create_app
work = Path(os.getenv("PRUNING_WORK_ROOT", "/home/user/work"))
inputs = Path(os.getenv("PRUNING_INPUT_ROOT", str(work / "inputs")))
inputs.mkdir(parents=True, exist_ok=True)
app = create_app(
inputs,
work / "jobs",
workers=1,
queue_size=int(os.getenv("PRUNING_QUEUE_SIZE", "1")),
threads_per_job=int(os.getenv("PRUNING_THREADS", str(min(2, len(os.sched_getaffinity(0)))))),
max_weights=int(os.getenv("PRUNING_MAX_WEIGHTS", "6000000000")),
token=os.getenv("TENSOR_PRUNING_API_TOKEN"),
require_token=True,
checkpoint_root=os.getenv("PRUNING_CHECKPOINT_ROOT", "/models"),
)
@app.get("/", include_in_schema=False)
def index():
return RedirectResponse("/docs")
|