nalin0503 commited on
Commit
6cce645
·
1 Parent(s): 7abdb33

Update dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -4
Dockerfile CHANGED
@@ -1,9 +1,11 @@
1
- FROM nvidia/cuda:12.3.2-cudnn9-devel-ubuntu22.04
2
 
3
  # Set environment variables
4
  ENV DEBIAN_FRONTEND=noninteractive
5
  ENV PYTHONUNBUFFERED=1
6
  ENV PYTHONDONTWRITEBYTECODE=1
 
 
7
 
8
  # Install system dependencies
9
  RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -24,15 +26,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
24
  # Set working directory
25
  WORKDIR /app
26
 
27
- # Copy requirements.txt
28
  COPY requirements.txt /app/
 
29
 
30
  # Install Python dependencies
31
  RUN pip3 install --no-cache-dir --upgrade pip setuptools wheel
32
  RUN pip3 install --no-cache-dir -r requirements.txt
33
 
34
- # Install OpenCV with CUDA support
35
- RUN pip3 install --no-cache-dir opencv-python-headless opencv-contrib-python-headless
36
 
37
  # Copy application code
38
  COPY . /app/
@@ -41,10 +44,18 @@ COPY . /app/
41
  RUN chmod +x /app/run_morphing.py
42
  RUN chmod +x /app/FILM.py
43
 
 
 
 
 
 
44
  # Set environment variables for CUDA
45
  ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
46
  ENV PATH=/usr/local/cuda/bin:${PATH}
47
 
 
 
 
48
  # Expose port for Streamlit
49
  EXPOSE 8501
50
 
 
1
+ FROM nvidia/cuda:12.2.0-cudnn8-devel-ubuntu22.04
2
 
3
  # Set environment variables
4
  ENV DEBIAN_FRONTEND=noninteractive
5
  ENV PYTHONUNBUFFERED=1
6
  ENV PYTHONDONTWRITEBYTECODE=1
7
+ ENV TF_FORCE_GPU_ALLOW_GROWTH=true
8
+ ENV XLA_FLAGS="--xla_gpu_enable_fast_min_max"
9
 
10
  # Install system dependencies
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
26
  # Set working directory
27
  WORKDIR /app
28
 
29
+ # Copy requirements.txt but modify TensorFlow version
30
  COPY requirements.txt /app/
31
+ RUN sed -i 's/tensorflow==2.18.0/tensorflow==2.15.0/' /app/requirements.txt
32
 
33
  # Install Python dependencies
34
  RUN pip3 install --no-cache-dir --upgrade pip setuptools wheel
35
  RUN pip3 install --no-cache-dir -r requirements.txt
36
 
37
+ # Install compatible OpenCV with CUDA support
38
+ RUN pip3 install --no-cache-dir opencv-python-headless==4.5.5.64 opencv-contrib-python-headless==4.5.5.64
39
 
40
  # Copy application code
41
  COPY . /app/
 
44
  RUN chmod +x /app/run_morphing.py
45
  RUN chmod +x /app/FILM.py
46
 
47
+ # Add FILM.py fallback to CPU if CUDA fails
48
+ RUN sed -i '/def __call__/a\ try:' /app/FILM.py && \
49
+ sed -i '/result = self._model/i\ # Try with GPU' /app/FILM.py && \
50
+ sed -i '/result = self._model/a\ except Exception as e:\n print("GPU inference failed, falling back to CPU")\n # Force CPU execution\n with tf.device("/cpu:0"):\n result = self._model(inputs, training=False)' /app/FILM.py
51
+
52
  # Set environment variables for CUDA
53
  ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
54
  ENV PATH=/usr/local/cuda/bin:${PATH}
55
 
56
+ # Force TensorFlow to use compatible cuDNN version
57
+ ENV TF_CUDNN_VERSION=8
58
+
59
  # Expose port for Streamlit
60
  EXPOSE 8501
61