Skip to content

Commit c45c3c9

Browse files
docker: fix setting tags (#20504)
* docker: fix setting tags * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * pip install * cmd * latest * print * cuda 12.1.1 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent f9babd1 commit c45c3c9

File tree

3 files changed

+47
-37
lines changed

3 files changed

+47
-37
lines changed

.actions/assistant.py

+19
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,25 @@ def convert_version2nightly(ver_file: str = "src/version.info") -> None:
481481
with open(ver_file, "w") as fo:
482482
fo.write(version + os.linesep)
483483

484+
@staticmethod
485+
def generate_docker_tags(
486+
release_version: str,
487+
python_version: str,
488+
torch_version: str,
489+
cuda_version: str,
490+
docker_project: str = "pytorchlightning/pytorch_lightning",
491+
add_latest: bool = False,
492+
) -> None:
493+
"""Generate docker tags for the given versions."""
494+
tags = [f"latest-py{python_version}-torch{torch_version}-cuda{cuda_version}"]
495+
if release_version:
496+
tags += [f"{release_version}-py{python_version}-torch{torch_version}-cuda{cuda_version}"]
497+
if add_latest:
498+
tags += ["latest"]
499+
500+
tags = [f"{docker_project}:{tag}" for tag in tags]
501+
print(",".join(tags))
502+
484503

485504
if __name__ == "__main__":
486505
import sys

.github/checkgroup.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,17 @@ subprojects:
145145
- "!*.md"
146146
- "!**/*.md"
147147
checks:
148-
- "build-cuda (3.10, 2.1.2, 12.1.0)"
149-
- "build-cuda (3.11, 2.2.2, 12.1.0)"
150-
- "build-cuda (3.11, 2.3.1, 12.1.0)"
151-
- "build-cuda (3.11, 2.4.1, 12.1.0)"
152-
- "build-cuda (3.12, 2.5.1, 12.1.0)"
148+
- "build-cuda (3.10, 2.1.2, 12.1.1)"
149+
- "build-cuda (3.11, 2.2.2, 12.1.1)"
150+
- "build-cuda (3.11, 2.3.1, 12.1.1)"
151+
- "build-cuda (3.11, 2.4.1, 12.1.1)"
152+
- "build-cuda (3.12, 2.5.1, 12.1.1)"
153153
#- "build-NGC"
154-
- "build-pl (3.10, 2.1, 12.1.0)"
155-
- "build-pl (3.11, 2.2, 12.1.0)"
156-
- "build-pl (3.11, 2.3, 12.1.0)"
157-
- "build-pl (3.11, 2.4, 12.1.0)"
158-
- "build-pl (3.12, 2.5, 12.1.0)"
154+
- "build-pl (3.10, 2.1, 12.1.1)"
155+
- "build-pl (3.11, 2.2, 12.1.1)"
156+
- "build-pl (3.11, 2.3, 12.1.1)"
157+
- "build-pl (3.11, 2.4, 12.1.1)"
158+
- "build-pl (3.12, 2.5, 12.1.1, true)"
159159

160160
# SECTION: lightning_fabric
161161

.github/workflows/docker-build.yml

+18-27
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ jobs:
4343
include:
4444
# We only release one docker image per PyTorch version.
4545
# Make sure the matrix here matches the one below.
46-
- { python_version: "3.10", pytorch_version: "2.1", cuda_version: "12.1.0" }
47-
- { python_version: "3.11", pytorch_version: "2.2", cuda_version: "12.1.0" }
48-
- { python_version: "3.11", pytorch_version: "2.3", cuda_version: "12.1.0" }
49-
- { python_version: "3.11", pytorch_version: "2.4", cuda_version: "12.1.0" }
50-
- { python_version: "3.12", pytorch_version: "2.5", cuda_version: "12.1.0" }
46+
- { python_version: "3.10", pytorch_version: "2.1", cuda_version: "12.1.1" }
47+
- { python_version: "3.11", pytorch_version: "2.2", cuda_version: "12.1.1" }
48+
- { python_version: "3.11", pytorch_version: "2.3", cuda_version: "12.1.1" }
49+
- { python_version: "3.11", pytorch_version: "2.4", cuda_version: "12.1.1" }
50+
- { python_version: "3.12", pytorch_version: "2.5", cuda_version: "12.1.1", latest: "true" }
5151
steps:
5252
- uses: actions/checkout@v4
5353
with:
@@ -65,23 +65,14 @@ jobs:
6565
run: echo "RELEASE_VERSION=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
6666
- name: Set tags
6767
run: |
68-
import os
69-
70-
repo = "pytorchlightning/pytorch_lightning"
71-
ver = os.getenv('RELEASE_VERSION')
72-
py_ver = "${{ matrix.python_version }}"
73-
pt_ver = "${{ matrix.pytorch_version }}"
74-
cuda_ver = "${{ matrix.cuda_version }}"
75-
tags = [f"latest-py{py_ver}-torch{pt_ver}-cuda{cuda_ver}"]
76-
if ver:
77-
tags += [f"{ver}-py{py_ver}-torch{pt_ver}-cuda{cuda_ver}"]
78-
if py_ver == '3.11' and pt_ver == '2.3' and cuda_ver == '12.1.0':
79-
tags += ["latest"]
80-
81-
tags = [f"{repo}:{tag}" for tag in tags]
82-
with open(os.getenv('GITHUB_ENV'), "a") as gh_env:
83-
gh_env.write("DOCKER_TAGS=" + ",".join(tags))
84-
shell: python
68+
pip install -q -r .actions/requirements.txt
69+
tags=$(python .actions/assistant.py generate_docker_tags \
70+
--release_version="${{ env.RELEASE_VERSION }}" \
71+
--python_version="${{ matrix.python_version }}" \
72+
--torch_version="${{ matrix.pytorch_version }}" \
73+
--cuda_version="${{ matrix.cuda_version }}" \
74+
--add_latest="${{ matrix.latest || 'false' }}")
75+
echo "DOCKER_TAGS=$tags" >> $GITHUB_ENV
8576
8677
- uses: docker/build-push-action@v6
8778
with:
@@ -104,11 +95,11 @@ jobs:
10495
include:
10596
# These are the base images for PL release docker images.
10697
# Make sure the matrix here matches the one above.
107-
- { python_version: "3.10", pytorch_version: "2.1.2", cuda_version: "12.1.0" }
108-
- { python_version: "3.11", pytorch_version: "2.2.2", cuda_version: "12.1.0" }
109-
- { python_version: "3.11", pytorch_version: "2.3.1", cuda_version: "12.1.0" }
110-
- { python_version: "3.11", pytorch_version: "2.4.1", cuda_version: "12.1.0" }
111-
- { python_version: "3.12", pytorch_version: "2.5.1", cuda_version: "12.1.0" }
98+
- { python_version: "3.10", pytorch_version: "2.1.2", cuda_version: "12.1.1" }
99+
- { python_version: "3.11", pytorch_version: "2.2.2", cuda_version: "12.1.1" }
100+
- { python_version: "3.11", pytorch_version: "2.3.1", cuda_version: "12.1.1" }
101+
- { python_version: "3.11", pytorch_version: "2.4.1", cuda_version: "12.1.1" }
102+
- { python_version: "3.12", pytorch_version: "2.5.1", cuda_version: "12.1.1" }
112103
steps:
113104
- uses: actions/checkout@v4
114105
- uses: docker/setup-buildx-action@v3

0 commit comments

Comments
 (0)