Peter Michael Gits Claude commited on
Commit
049566b
·
1 Parent(s): d764d2b

Fix OMP_NUM_THREADS warning and restart loop issues

Browse files

v1.3.10 - Final fixes for clean startup:
1. Moved OMP_NUM_THREADS=1 to Dockerfile ENV (not Python os.environ)
2. Moved all HF cache environment variables to Dockerfile ENV
3. Extended health check timing: 300s start period, 60s interval, 5 retries
(allows more time for Moshi model loading without failing health checks)
4. Cleaned up Python environment variable setting code

Should eliminate both libgomp warning and restart loops

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (2) hide show
  1. Dockerfile +8 -2
  2. app.py +3 -8
Dockerfile CHANGED
@@ -43,11 +43,17 @@ RUN chown -R appuser:appuser /app
43
  # Switch back to non-root user for running the app
44
  USER appuser
45
 
 
 
 
 
 
 
46
  # Expose port
47
  EXPOSE 7860
48
 
49
- # Health check
50
- HEALTHCHECK --interval=30s --timeout=30s --start-period=180s --retries=3 \
51
  CMD curl -f http://localhost:7860/health || exit 1
52
 
53
  # Run application as non-root user
 
43
  # Switch back to non-root user for running the app
44
  USER appuser
45
 
46
+ # Set environment variables to fix OpenMP and caching issues
47
+ ENV OMP_NUM_THREADS=1
48
+ ENV HF_HOME=/app/hf_cache
49
+ ENV HUGGINGFACE_HUB_CACHE=/app/hf_cache
50
+ ENV TRANSFORMERS_CACHE=/app/hf_cache
51
+
52
  # Expose port
53
  EXPOSE 7860
54
 
55
+ # Health check - allow more time for model loading
56
+ HEALTHCHECK --interval=60s --timeout=45s --start-period=300s --retries=5 \
57
  CMD curl -f http://localhost:7860/health || exit 1
58
 
59
  # Run application as non-root user
app.py CHANGED
@@ -6,13 +6,8 @@ import os
6
  from typing import Optional
7
  from contextlib import asynccontextmanager
8
 
9
- # Fix OpenMP warning - MUST be set before importing torch
10
- os.environ['OMP_NUM_THREADS'] = '1'
11
-
12
- # Fix cache directory permissions - set to writable directory
13
- os.environ['HF_HOME'] = '/app/hf_cache'
14
- os.environ['HUGGINGFACE_HUB_CACHE'] = '/app/hf_cache'
15
- os.environ['TRANSFORMERS_CACHE'] = '/app/hf_cache'
16
 
17
  import torch
18
  import numpy as np
@@ -21,7 +16,7 @@ from fastapi.responses import JSONResponse, HTMLResponse
21
  import uvicorn
22
 
23
  # Version tracking
24
- VERSION = "1.3.9"
25
  COMMIT_SHA = "TBD"
26
 
27
  # Configure logging
 
6
  from typing import Optional
7
  from contextlib import asynccontextmanager
8
 
9
+ # Environment variables now set in Dockerfile
10
+ # OMP_NUM_THREADS=1, HF_HOME=/app/hf_cache, etc.
 
 
 
 
 
11
 
12
  import torch
13
  import numpy as np
 
16
  import uvicorn
17
 
18
  # Version tracking
19
+ VERSION = "1.3.10"
20
  COMMIT_SHA = "TBD"
21
 
22
  # Configure logging