sayeed105236 commited on
Commit
57fa6f9
·
1 Parent(s): 11e2761

Fix: comprehensive deps + monkey-patch wan/__init__.py to tolerate missing optional modules

Browse files
Files changed (1) hide show
  1. Dockerfile +39 -18
Dockerfile CHANGED
@@ -5,7 +5,7 @@ FROM nvidia/cuda:12.4.0-runtime-ubuntu22.04
5
  RUN apt-get update && apt-get install -y \
6
  python3.10 python3.10-dev python3-pip \
7
  ffmpeg libsm6 libxext6 libgl1 \
8
- git \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
  RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
@@ -19,29 +19,50 @@ ENV PYTHONUNBUFFERED=1
19
 
20
  WORKDIR /app
21
 
22
- # Clone official Wan2.2 repo
23
  RUN git clone https://github.com/Wan-Video/Wan2.2.git /app/Wan2.2
24
 
25
  # PyTorch
26
  RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
27
 
28
- # Install ALL deps
 
 
 
29
  RUN pip install --no-cache-dir \
30
- opencv-python>=4.9.0.80 \
31
- diffusers>=0.31.0 \
32
- "transformers>=4.49.0,<=4.51.3" \
33
- tokenizers>=0.20.3 \
34
- accelerate>=1.1.1 \
35
- tqdm \
36
- "imageio[ffmpeg]" \
37
- easydict \
38
- ftfy \
39
- imageio-ffmpeg \
40
- einops \
41
- decord \
42
- librosa \
43
- sentencepiece \
44
- "numpy>=1.23.5,<2"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  # FastAPI
47
  COPY --chown=user ./requirements.txt requirements.txt
 
5
  RUN apt-get update && apt-get install -y \
6
  python3.10 python3.10-dev python3-pip \
7
  ffmpeg libsm6 libxext6 libgl1 \
8
+ git libsndfile1 \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
  RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
 
19
 
20
  WORKDIR /app
21
 
22
+ # Clone official Wan2.2
23
  RUN git clone https://github.com/Wan-Video/Wan2.2.git /app/Wan2.2
24
 
25
  # PyTorch
26
  RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
27
 
28
+ # Install everything from the Wan2.2 requirements (flash_attn may fail on T4, that's ok)
29
+ RUN cd /app/Wan2.2 && (pip install --no-cache-dir -r requirements.txt 2>/dev/null; true)
30
+
31
+ # Fill in any missing deps aggressively
32
  RUN pip install --no-cache-dir \
33
+ opencv-python easydict decord librosa peft sentencepiece protobuf \
34
+ diffusers transformers accelerate tokenizers \
35
+ tqdm ftfy "imageio[ffmpeg]" imageio-ffmpeg einops \
36
+ "numpy>=1.23.5,<2" soundfile
37
+
38
+ # Patch Wan2.2 to tolerate missing optional modules at import time
39
+ RUN python -c "
40
+ content = '''# Patched for Docker Space — tolerate missing optional modules
41
+ import importlib, sys
42
+
43
+ _module_fallbacks = {
44
+ 'wan.speech2video': 'speech2video optional',
45
+ 'wan.animate': 'animate optional',
46
+ }
47
+
48
+ _orig_import = __import__
49
+ def _safe_import(name, *args, **kwargs):
50
+ try:
51
+ return _orig_import(name, *args, **kwargs)
52
+ except (ImportError, ModuleNotFoundError) as e:
53
+ if name in _module_fallbacks:
54
+ return type(sys)(name)
55
+ raise
56
+
57
+ import builtins
58
+ builtins.__import__ = _safe_import
59
+ '''
60
+ with open('/app/Wan2.2/wan/__init__.py', 'r') as f:
61
+ original = f.read()
62
+ with open('/app/Wan2.2/wan/__init__.py', 'w') as f:
63
+ f.write(content + '\\n' + original)
64
+ print('Patched wan/__init__.py')
65
+ "
66
 
67
  # FastAPI
68
  COPY --chown=user ./requirements.txt requirements.txt