Skip to content

Commit 9fae6c8

Browse files
authored
Merge pull request #267 from allenai/favyen/20251215-speed-up-docker-build
Update olmoearth_pretrain.Dockerfile to speed up builds that use it.
2 parents 030c153 + 6afc0c4 commit 9fae6c8

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

olmoearth_pretrain.Dockerfile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ FROM pytorch/pytorch:2.7.0-cuda12.8-cudnn9-runtime
33
RUN apt update
44
RUN apt install -y libpq-dev ffmpeg libsm6 libxext6 git wget
55

6-
# Install rslearn and olmoearth_pretrain (need to be in local directory).
7-
COPY ./docker_build/rslearn /opt/rslearn
8-
COPY ./docker_build/olmoearth_pretrain /opt/olmoearth_pretrain
9-
10-
# We also install terratorch so that we can use the same Docker image for TerraMind
11-
# experiments.
12-
RUN pip install --no-cache-dir git+https://github.com/IBM/terratorch.git
13-
RUN pip install --no-cache-dir geobench==0.0.1
14-
15-
RUN pip install --no-cache-dir --upgrade /opt/rslearn[extra]
16-
RUN pip install --no-cache-dir --upgrade /opt/olmoearth_pretrain
6+
# Use uv to install everything.
7+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
178

18-
COPY requirements-without-rslearn.txt /opt/rslearn_projects/requirements-without-rslearn.txt
9+
# Install dependencies for rslearn, olmoearth_pretrain, and rslearn_projects.
10+
COPY docker_build/rslearn/pyproject.toml /opt/rslearn/pyproject.toml
11+
COPY docker_build/olmoearth_pretrain/pyproject.toml /opt/olmoearth_pretrain/pyproject.toml
12+
COPY requirements.txt /opt/rslearn_projects/requirements.txt
1913
COPY requirements-extra.txt /opt/rslearn_projects/requirements-extra.txt
20-
RUN pip install --no-cache-dir -r /opt/rslearn_projects/requirements-without-rslearn.txt -r /opt/rslearn_projects/requirements-extra.txt
14+
# Using cache mount here avoids needing to re-download dependencies for later builds if the version didn't change.
15+
RUN --mount=type=cache,target=/root/.cache/uv uv pip install --system /opt/rslearn[extra] /opt/olmoearth_pretrain -r /opt/rslearn_projects/requirements.txt -r /opt/rslearn_projects/requirements-extra.txt
2116

22-
# Copy rslearn_projects and install it too.
17+
# Now copy the source code and install for real.
18+
# If we don't change any dependencies, then only these steps need to be repeated
19+
# (fast and means the new layers have small size).
20+
COPY ./docker_build/rslearn /opt/rslearn
21+
COPY ./docker_build/olmoearth_pretrain /opt/olmoearth_pretrain
2322
COPY . /opt/rslearn_projects/
24-
RUN pip install --no-cache-dir /opt/rslearn_projects
23+
24+
RUN --mount=type=cache,target=/root/.cache/uv uv pip install --system /opt/rslearn[extra] /opt/olmoearth_pretrain /opt/rslearn_projects[extra]
2525

2626
WORKDIR /opt/rslearn_projects

rslp/forest_loss_driver/extract_dataset/__init__.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,27 @@ class InferenceLayerMaterializeArgs(MaterializePipelineArgs):
6767
prepare_args: PrepareArgs = field(
6868
default_factory=lambda: PrepareArgs(
6969
apply_windows_args=ApplyWindowsArgs(
70-
use_initial_job=True, workers=get_default_workers()
70+
use_initial_job=True,
71+
workers=get_default_workers(),
7172
),
73+
retry_max_attempts=5,
74+
retry_backoff=timedelta(seconds=5),
7275
)
7376
)
7477
ingest_args: IngestArgs = field(
7578
default_factory=lambda: IngestArgs(
7679
ignore_errors=True,
7780
apply_windows_args=ApplyWindowsArgs(workers=get_default_workers()),
81+
retry_max_attempts=5,
82+
retry_backoff=timedelta(seconds=5),
7883
)
7984
)
8085
materialize_args: MaterializeArgs = field(
8186
default_factory=lambda: MaterializeArgs(
8287
ignore_errors=True,
8388
apply_windows_args=ApplyWindowsArgs(workers=get_default_workers()),
89+
retry_max_attempts=5,
90+
retry_backoff=timedelta(seconds=5),
8491
),
8592
)
8693

@@ -104,22 +111,23 @@ class VisLayerMaterializeArgs(MaterializePipelineArgs):
104111
apply_windows_args=ApplyWindowsArgs(
105112
use_initial_job=True, workers=DEFAULT_VIS_LAYER_WORKERS
106113
),
107-
retry_max_attempts=20,
108-
retry_backoff=timedelta(seconds=30),
114+
retry_max_attempts=5,
115+
retry_backoff=timedelta(seconds=5),
109116
),
110117
)
111118
ingest_args: IngestArgs = field(
112119
default_factory=lambda: IngestArgs(
113120
apply_windows_args=ApplyWindowsArgs(workers=DEFAULT_VIS_LAYER_WORKERS),
114121
retry_max_attempts=5,
122+
retry_backoff=timedelta(seconds=5),
115123
)
116124
)
117125
materialize_args: MaterializeArgs = field(
118126
default_factory=lambda: MaterializeArgs(
119127
ignore_errors=True,
120128
apply_windows_args=ApplyWindowsArgs(workers=DEFAULT_VIS_LAYER_WORKERS),
121129
retry_max_attempts=5,
122-
retry_backoff=timedelta(seconds=30),
130+
retry_backoff=timedelta(seconds=5),
123131
),
124132
)
125133

0 commit comments

Comments
 (0)