akra35567 commited on
Commit
95affee
·
1 Parent(s): 5e7b481

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +40 -12
Dockerfile CHANGED
@@ -1,43 +1,71 @@
1
- # Dockerfile – BAIXA HERMES 7B SEM CARREGAR NA RAM (OOM FIX)
2
  FROM python:3.11-slim
3
 
4
  ENV DEBIAN_FRONTEND=noninteractive \
5
  PYTHONUNBUFFERED=1 \
6
- PYTHONDONTWRITEBYTECODE=1
 
 
7
 
 
8
  RUN apt-get update && \
9
- apt-get install -y --no-install-recommends curl wget git ca-certificates && \
 
10
  rm -rf /var/lib/apt/lists/*
11
 
12
  WORKDIR /app
13
 
 
14
  COPY requirements.txt .
15
  COPY modules/ modules/
16
  COPY main.py .
17
 
18
- # Instala dependências
19
  RUN pip install --upgrade pip && \
20
  pip install --no-cache-dir torch==2.4.1 --index-url https://download.pytorch.org/whl/cpu && \
21
  pip install --no-cache-dir -r requirements.txt && \
22
- pip install --no-cache-dir huggingface_hub sentencepiece
 
 
 
 
 
 
23
 
24
- # BAIXA HERMES 7B OS ARQUIVOS (SEM CARREGAR NA RAM!)
25
  RUN python - <<'EOF'
26
  from huggingface_hub import snapshot_download
27
  import os
28
- print('BAIXANDO HERMES 7B (SÓ ARQUIVOS, SEM RAM)...')
29
- model_name = "NousResearch/Hermes-2-Pro-Mistral-7B"
 
30
  snapshot_download(
31
- repo_id=model_name,
32
  local_dir="/app/models/hermes-7b",
33
  local_dir_use_symlinks=False,
34
  resume_download=True,
35
- allow_patterns=["*.json", "*.bin", "*.model", "tokenizer*", "generation_config.json"]
 
 
 
 
 
 
36
  )
37
- print('HERMES 7B BAIXADO (SÓ DISCO)!')
 
 
 
 
 
 
 
 
38
  EOF
39
 
40
- RUN mkdir -p /app/data/finetuned_hermes
 
41
 
42
  EXPOSE 7860
 
43
  CMD ["gunicorn", "--workers", "1", "--threads", "2", "--timeout", "300", "--bind", "0.0.0.0:7860", "main:app"]
 
1
+ # Dockerfile – FORÇA .safetensors + VERIFICAÇÃO RÍGIDA
2
  FROM python:3.11-slim
3
 
4
  ENV DEBIAN_FRONTEND=noninteractive \
5
  PYTHONUNBUFFERED=1 \
6
+ PYTHONDONTWRITEBYTECODE=1 \
7
+ HF_HUB_ENABLE_HF_TRANSFER=1 \
8
+ PIP_NO_CACHE_DIR=1
9
 
10
+ # Instala dependências
11
  RUN apt-get update && \
12
+ apt-get install -y --no-install-recommends \
13
+ curl wget git ca-certificates gcc g++ && \
14
  rm -rf /var/lib/apt/lists/*
15
 
16
  WORKDIR /app
17
 
18
+ # Copia arquivos
19
  COPY requirements.txt .
20
  COPY modules/ modules/
21
  COPY main.py .
22
 
23
+ # Instala PyTorch CPU + HF + extras
24
  RUN pip install --upgrade pip && \
25
  pip install --no-cache-dir torch==2.4.1 --index-url https://download.pytorch.org/whl/cpu && \
26
  pip install --no-cache-dir -r requirements.txt && \
27
+ pip install --no-cache-dir \
28
+ huggingface_hub[hf_transfer] \
29
+ sentencepiece \
30
+ sentence-transformers \
31
+ peft \
32
+ datasets \
33
+ accelerate
34
 
35
+ # BAIXA HERMES 7B COM .safetensors OBRIGATÓRIO
36
  RUN python - <<'EOF'
37
  from huggingface_hub import snapshot_download
38
  import os
39
+ import sys
40
+
41
+ print("BAIXANDO HERMES 7B (FORÇANDO .safetensors)...")
42
  snapshot_download(
43
+ repo_id="NousResearch/Hermes-2-Pro-Mistral-7B",
44
  local_dir="/app/models/hermes-7b",
45
  local_dir_use_symlinks=False,
46
  resume_download=True,
47
+ allow_patterns=[
48
+ "config.json",
49
+ "generation_config.json",
50
+ "tokenizer*",
51
+ "model-*-of-*.safetensors" # FORÇA .safetensors
52
+ ],
53
+ ignore_patterns=["*.bin", "*.msgpack"] # IGNORA .bin
54
  )
55
+
56
+ # VERIFICA 4 SHARDS .safetensors
57
+ shards = [f for f in os.listdir("/app/models/hermes-7b") if f.endswith(".safetensors")]
58
+ if len(shards) != 4:
59
+ print(f"ERRO: {len(shards)} SHARDS .safetensors ENCONTRADOS! ESPERADO: 4")
60
+ print("SHARDS:", shards)
61
+ sys.exit(1)
62
+
63
+ print(f"SUCESSO: {len(shards)} SHARDS .safetensors BAIXADOS!")
64
  EOF
65
 
66
+ # Cria pastas persistentes
67
+ RUN mkdir -p /app/data/finetuned_hermes /tmp/offload
68
 
69
  EXPOSE 7860
70
+
71
  CMD ["gunicorn", "--workers", "1", "--threads", "2", "--timeout", "300", "--bind", "0.0.0.0:7860", "main:app"]