fffiloni commited on
Commit
233c08c
·
verified ·
1 Parent(s): d2f7cfa

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -24
Dockerfile CHANGED
@@ -1,11 +1,11 @@
1
- # Use the NVIDIA CUDA runtime as a base image
2
  FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
3
 
4
  # Set environment variables
5
  ENV DEBIAN_FRONTEND=noninteractive
6
 
 
7
  RUN useradd -m -u 1000 user
8
-
9
  USER user
10
 
11
  ENV HOME=/home/user \
@@ -25,7 +25,7 @@ ENV HOME=/home/user \
25
  # Set the working directory to the user's home directory
26
  WORKDIR $HOME/app
27
 
28
- # Install Conda and create the environment
29
  USER root
30
  RUN apt-get update && apt-get install -y \
31
  wget \
@@ -35,30 +35,32 @@ RUN apt-get update && apt-get install -y \
35
  gnupg \
36
  libgl1-mesa-glx \
37
  libglib2.0-0 \
38
- && wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh \
39
- && bash miniconda.sh -b -p /opt/conda \
40
- && rm miniconda.sh \
41
- && /opt/conda/bin/conda init bash \
42
- && /opt/conda/bin/conda update -n base -c defaults conda \
43
- && /opt/conda/bin/conda install -y -c conda-forge mamba \
44
- && /opt/conda/bin/mamba install -c nvidia -c pytorch -c conda-forge -c defaults python=3.9 pytorch=2.5.1 torchvision=0.20.1 torchaudio=2.5.1 pytorch-cuda=11.8 timm scikit-learn matplotlib pandas \
45
- && rm -rf /var/lib/apt/lists/*
46
 
47
- # Verify installation
48
- RUN /opt/conda/bin/conda --version
49
- RUN /opt/conda/bin/python --version
50
- RUN /opt/conda/bin/python -c "import torch; print(torch.__version__)"
 
 
 
 
51
 
52
- USER user
53
- # Create the environment and activate it
54
- RUN /opt/conda/bin/conda env create -f /home/user/app/environment.yaml
55
- RUN echo "conda activate gazelle" >> ~/.bashrc
56
 
57
- # Install additional Python dependencies
 
58
  COPY . .
59
- RUN /opt/conda/bin/pip install --upgrade pip
60
- RUN /opt/conda/bin/pip install -r requirements.txt
61
- RUN /opt/conda/bin/pip install gradio
62
 
63
  USER root
64
  # Configure git to trust the directory
@@ -72,4 +74,4 @@ ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
72
  ENV CUDA_VISIBLE_DEVICES=0
73
 
74
  # Command to run your application
75
- CMD ["/opt/conda/bin/python", "app.py"]
 
1
+ # Use the NVIDIA CUDA runtime as a base image for CUDA 11.8
2
  FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
3
 
4
  # Set environment variables
5
  ENV DEBIAN_FRONTEND=noninteractive
6
 
7
+ # Create a user and set environment variables
8
  RUN useradd -m -u 1000 user
 
9
  USER user
10
 
11
  ENV HOME=/home/user \
 
25
  # Set the working directory to the user's home directory
26
  WORKDIR $HOME/app
27
 
28
+ # Install system dependencies as root
29
  USER root
30
  RUN apt-get update && apt-get install -y \
31
  wget \
 
35
  gnupg \
36
  libgl1-mesa-glx \
37
  libglib2.0-0 \
38
+ python3.9 \
39
+ python3.9-distutils \
40
+ python3.9-dev \
41
+ && curl -sS https://bootstrap.pypa.io/get-pip.py | python3.9 \
42
+ && update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 \
43
+ && update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip 1 \
44
+ && apt-get clean
 
45
 
46
+ # Install CUDA 11.8 and cuDNN 9.3.0 directly from NVIDIA's repositories
47
+ RUN curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub | gpg --batch --yes --dearmor -o /usr/share/keyrings/cuda-archive-keyring.gpg \
48
+ && echo "deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /" > /etc/apt/sources.list.d/cuda.list \
49
+ && apt-get update && apt-get install -y \
50
+ libcudnn9=8.9.3.0-1+cuda11.8 \
51
+ libcudnn9-dev=8.9.3.0-1+cuda11.8 \
52
+ libcudnn9-doc=8.9.3.0-1+cuda11.8 \
53
+ && apt-get clean
54
 
55
+ # Verify CUDA and cuDNN installation
56
+ RUN dpkg-query -W libcudnn9
 
 
57
 
58
+ # Install Python dependencies
59
+ USER user
60
  COPY . .
61
+ RUN pip install --upgrade pip
62
+ RUN pip install -r requirements.txt
63
+ RUN pip install gradio
64
 
65
  USER root
66
  # Configure git to trust the directory
 
74
  ENV CUDA_VISIBLE_DEVICES=0
75
 
76
  # Command to run your application
77
+ CMD ["python", "app.py"]