-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.GPU
72 lines (52 loc) · 2.13 KB
/
Dockerfile.GPU
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# syntax=docker/dockerfile:1.4
# Use an x86_64 base image explicitly
FROM --platform=linux/amd64 nvidia/cuda:12.5.0-base-ubuntu22.04 AS base
# Set working directory
WORKDIR /usr/src/swabber
# Install required system packages
RUN apt-get update --fix-missing && \
apt-get install -y wget bzip2 ca-certificates curl git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install QEMU for x86_64 emulation
RUN apt-get update && \
apt-get install -y qemu-user-static
# Install Miniconda in a separate build stage
FROM base AS miniconda
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh && \
/bin/bash /tmp/miniconda.sh -b -p /opt/conda && \
rm /tmp/miniconda.sh && \
/opt/conda/bin/conda clean -a && \
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
echo "conda activate base" >> ~/.bashrc
# Continue from the base image
FROM base
# Copy Miniconda installation from the previous stage
COPY --from=miniconda /opt/conda /opt/conda
# Set environment variables
ENV PATH /opt/conda/bin:$PATH
# Copy conda environment file
COPY envs/conda/environment.yml .
# Copy pip environment file
COPY envs/pip/requirements.txt .
# Create environment from yaml file
RUN conda env create -f environment.yml && conda clean -afy
# Set up bash to run with swabber conda environment
SHELL ["conda", "run", "-n", "swabber", "/bin/bash", "-c"]
# Set PATH for the Conda environment
ENV PATH /opt/conda/envs/swabber/bin:$PATH
# Install ipykernel
RUN pip install --no-cache-dir ipykernel
# Add swabber conda env to ipykernel to run Notebooks
RUN python -m ipykernel install --user --name=swabber --display-name "Swabber"
# Install basic dev tools, like GCC
RUN apt update -y && apt upgrade -y && apt install -y build-essential && apt-get install -y manpages-dev
# Switch back to bash
SHELL ["/bin/bash", "-c"]
# Initialize conda
RUN conda init
# Activate swabber environment on bash startup
RUN echo 'conda activate swabber' >> ~/.bashrc
# Install requirements
RUN pip install --no-cache-dir -r requirements.txt