KillerKing93 commited on
Commit
9f99713
·
verified ·
1 Parent(s): c996e04

Sync from GitHub 1e79046

Browse files
Files changed (2) hide show
  1. Dockerfile +2 -1
  2. main.py +10 -2
Dockerfile CHANGED
@@ -23,6 +23,7 @@ ARG BACKEND=cpu
23
  # - CUDA cu124 index publishes up to 2.6.0 (auto-resolves to +cu124)
24
  # - ROCm 6.2 index publishes up to 2.5.1+rocm6.2 (must include local tag)
25
  ARG TORCH_VER_CPU=2.9.0
 
26
  ARG TORCH_VER_NVIDIA=2.6.0
27
  ARG TORCH_VER_AMD=2.5.1+rocm6.2
28
 
@@ -35,7 +36,7 @@ ENV PIP_NO_CACHE_DIR=1
35
 
36
  # Install appropriate PyTorch for the selected backend, then the rest
37
  RUN if [ "$BACKEND" = "cpu" ]; then \
38
- pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch==${TORCH_VER_CPU}; \
39
  elif [ "$BACKEND" = "nvidia" ]; then \
40
  pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cu124 torch==${TORCH_VER_NVIDIA}; \
41
  elif [ "$BACKEND" = "amd" ]; then \
 
23
  # - CUDA cu124 index publishes up to 2.6.0 (auto-resolves to +cu124)
24
  # - ROCm 6.2 index publishes up to 2.5.1+rocm6.2 (must include local tag)
25
  ARG TORCH_VER_CPU=2.9.0
26
+ ARG TORCHVISION_VER_CPU=0.24.0
27
  ARG TORCH_VER_NVIDIA=2.6.0
28
  ARG TORCH_VER_AMD=2.5.1+rocm6.2
29
 
 
36
 
37
  # Install appropriate PyTorch for the selected backend, then the rest
38
  RUN if [ "$BACKEND" = "cpu" ]; then \
39
+ pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch==${TORCH_VER_CPU} torchvision==${TORCHVISION_VER_CPU}; \
40
  elif [ "$BACKEND" = "nvidia" ]; then \
41
  pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cu124 torch==${TORCH_VER_NVIDIA}; \
42
  elif [ "$BACKEND" = "amd" ]; then \
main.py CHANGED
@@ -105,8 +105,16 @@ def prefetch_model_assets(repo_id: str, token: Optional[str]) -> Optional[str]:
105
  - If CLI is unavailable, falls back to verbose API prefetch.
106
  """
107
  try:
108
- # Enable accelerated transfer + xet if available
109
- os.environ.setdefault("HF_HUB_ENABLE_HF_TRANSFER", "1")
 
 
 
 
 
 
 
 
110
  os.environ.setdefault("HF_HUB_ENABLE_XET", "1")
111
 
112
  cache_dir = os.getenv("HF_HOME") or os.getenv("TRANSFORMERS_CACHE") or ""
 
105
  - If CLI is unavailable, falls back to verbose API prefetch.
106
  """
107
  try:
108
+ # Enable accelerated transfer only if hf_transfer is installed; otherwise disable to avoid runtime errors on Spaces
109
+ try:
110
+ import importlib.util as _imputil
111
+ if _imputil.find_spec("hf_transfer") is not None:
112
+ os.environ.setdefault("HF_HUB_ENABLE_HF_TRANSFER", "1")
113
+ else:
114
+ os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "0"
115
+ except Exception:
116
+ os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "0"
117
+ # XET acceleration if available; harmless if missing
118
  os.environ.setdefault("HF_HUB_ENABLE_XET", "1")
119
 
120
  cache_dir = os.getenv("HF_HOME") or os.getenv("TRANSFORMERS_CACHE") or ""