root commited on
Commit
fd416ce
·
1 Parent(s): 0f5d521

change docker

Browse files
Files changed (3) hide show
  1. Dockerfile +20 -3
  2. app.py +0 -27
  3. requirements.txt +5 -5
Dockerfile CHANGED
@@ -1,20 +1,37 @@
1
- FROM witszhang/songgeneration_vllm:v2
 
 
 
 
 
2
 
3
  USER root
4
 
 
 
5
  RUN apt-get update && \
6
- apt-get install -y git-lfs && \
7
  git lfs install && \
8
  rm -rf /var/lib/apt/lists/*
9
 
10
  RUN useradd -m -u 1000 user
11
  USER user
12
  ENV PATH="/home/user/.local/bin:$PATH"
 
 
 
 
 
 
 
13
 
14
  WORKDIR /app
15
 
16
  COPY --chown=user ./requirements.txt requirements.txt
17
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
 
 
18
 
19
  COPY --chown=user . /app
20
  CMD ["python3", "app.py"]
 
1
+ FROM vllm/vllm-openai:v0.8.5
2
+
3
+ # The official vllm/vllm-openai image hard-codes
4
+ # ENTRYPOINT ["python3", "-m", "vllm.entrypoints.openai.api_server"]
5
+ # Clearing it makes our CMD ["python3", "app.py"] actually run.
6
+ ENTRYPOINT []
7
 
8
  USER root
9
 
10
+ # git-lfs : pulling model weights from HF
11
+ # ffmpeg / libsndfile1 : librosa needs them to decode mp3/m4a/ogg uploads
12
  RUN apt-get update && \
13
+ apt-get install -y --no-install-recommends git-lfs ffmpeg libsndfile1 && \
14
  git lfs install && \
15
  rm -rf /var/lib/apt/lists/*
16
 
17
  RUN useradd -m -u 1000 user
18
  USER user
19
  ENV PATH="/home/user/.local/bin:$PATH"
20
+ # Force Python stdout/stderr to be unbuffered so that progress bars (tqdm in
21
+ # snapshot_download), vLLM INFO logs and our own prints show up in HF Space
22
+ # logs immediately. Without this the container looks "stuck" at the startup
23
+ # banner because everything sits in a 4-8 KB block buffer until the process
24
+ # exits or the buffer fills up.
25
+ ENV PYTHONUNBUFFERED=1
26
+ ENV PYTHONIOENCODING=utf-8
27
 
28
  WORKDIR /app
29
 
30
  COPY --chown=user ./requirements.txt requirements.txt
31
+ # --prefer-binary : never try to build any wheel from source (flash_attn
32
+ # would OOM the build container). The base image already
33
+ # provides torch / vllm / flash_attn / transformers.
34
+ RUN pip install --no-cache-dir --upgrade --prefer-binary -r requirements.txt
35
 
36
  COPY --chown=user . /app
37
  CMD ["python3", "app.py"]
app.py CHANGED
@@ -6,21 +6,6 @@ import json
6
  import tempfile
7
  from datetime import datetime
8
 
9
- # ---------------------------------------------------------------------------
10
- # vLLM env tweaks – set BEFORE `import vllm` so they actually take effect.
11
- #
12
- # Why these are here:
13
- # * VLLM_USE_V1=0 -> stay on the single-process v0 engine. The default v1
14
- # engine forks an EngineCore subprocess which roughly doubles host RAM
15
- # because the 7B weights get loaded twice. That is the most common cause
16
- # of `exit 137 / OOMKilled` on hosts with limited RAM (HF Spaces etc.),
17
- # even when the GPU has plenty of free VRAM (L40s 48GB here).
18
- # * VLLM_WORKER_MULTIPROC_METHOD=fork -> if v1 is ever re-enabled, prefer
19
- # fork over spawn so weights are CoW-shared instead of reloaded.
20
- # ---------------------------------------------------------------------------
21
- os.environ.setdefault("VLLM_USE_V1", "0")
22
- os.environ.setdefault("VLLM_WORKER_MULTIPROC_METHOD", "fork")
23
-
24
  import gradio as gr
25
  import torch
26
  import torchaudio
@@ -67,23 +52,11 @@ class VllmInf:
67
  self.tokenizer = build_tokenizer(args)
68
  self.text_offset = len(self.tokenizer.tokenizer.get_vocab())
69
  self.max_tokens = 8192
70
- # NOTE on memory:
71
- # - swap_space=0 : disable the default 4 GiB CPU KV swap pool
72
- # (saves ~4 GB host RAM; GPU has plenty of
73
- # VRAM so we never need to swap).
74
- # - enforce_eager=True : skip CUDA-graph capture, which otherwise
75
- # allocates several GB of pinned/host
76
- # workspace at startup.
77
- # - gpu_memory_utilization stays at default (0.9) — we have a 48GB
78
- # L40s, the OOM is on host RAM, not VRAM.
79
  self.llm = LLM(
80
  model=model_path,
81
  trust_remote_code=True,
82
  max_model_len=self.max_tokens,
83
  dtype="bfloat16",
84
- swap_space=0,
85
- enforce_eager=True,
86
- disable_log_stats=True,
87
  )
88
 
89
  def run(self, audios):
 
6
  import tempfile
7
  from datetime import datetime
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  import gradio as gr
10
  import torch
11
  import torchaudio
 
52
  self.tokenizer = build_tokenizer(args)
53
  self.text_offset = len(self.tokenizer.tokenizer.get_vocab())
54
  self.max_tokens = 8192
 
 
 
 
 
 
 
 
 
55
  self.llm = LLM(
56
  model=model_path,
57
  trust_remote_code=True,
58
  max_model_len=self.max_tokens,
59
  dtype="bfloat16",
 
 
 
60
  )
61
 
62
  def run(self, audios):
requirements.txt CHANGED
@@ -1,10 +1,10 @@
1
  # Notes:
2
- # The base image `witszhang/songgeneration_vllm:v2` already ships:
3
- # - torch / torchaudio / torchvision (CUDA build)
4
  # - vllm 0.8.5
5
- # - transformers
6
- # - flash_attn (used by vllm backend)
7
- # Re-installing them here triggers a full source build of flash_attn
8
  # (no PyPI wheel available), which OOM-kills the HF Space *build*
9
  # container. Keep this list to lightweight, app-only dependencies.
10
  librosa>=0.11.0
 
1
  # Notes:
2
+ # The base image `vllm/vllm-openai:v0.8.5` already ships:
3
+ # - torch 2.6 / torchaudio / torchvision (CUDA 12.4 build)
4
  # - vllm 0.8.5
5
+ # - transformers (compatible with vllm 0.8.5)
6
+ # - flash_attn 2.7.x (used by vllm's flash-attn backend)
7
+ # Re-installing any of them here triggers a full source build of flash_attn
8
  # (no PyPI wheel available), which OOM-kills the HF Space *build*
9
  # container. Keep this list to lightweight, app-only dependencies.
10
  librosa>=0.11.0