Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: fix setting tags #20504

Merged
merged 9 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .actions/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,25 @@ def convert_version2nightly(ver_file: str = "src/version.info") -> None:
with open(ver_file, "w") as fo:
fo.write(version + os.linesep)

@staticmethod
def generate_docker_tags(
release_version: str,
python_version: str,
torch_version: str,
cuda_version: str,
docker_project: str = "pytorchlightning/pytorch_lightning",
add_latest: bool = False,
) -> None:
"""Generate docker tags for the given versions."""
tags = [f"latest-py{python_version}-torch{torch_version}-cuda{cuda_version}"]
if release_version:
tags += [f"{release_version}-py{python_version}-torch{torch_version}-cuda{cuda_version}"]
if add_latest:
tags += ["latest"]

tags = [f"{docker_project}:{tag}" for tag in tags]
print(",".join(tags))


if __name__ == "__main__":
import sys
Expand Down
20 changes: 10 additions & 10 deletions .github/checkgroup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,17 @@ subprojects:
- "!*.md"
- "!**/*.md"
checks:
- "build-cuda (3.10, 2.1.2, 12.1.0)"
- "build-cuda (3.11, 2.2.2, 12.1.0)"
- "build-cuda (3.11, 2.3.1, 12.1.0)"
- "build-cuda (3.11, 2.4.1, 12.1.0)"
- "build-cuda (3.12, 2.5.1, 12.1.0)"
- "build-cuda (3.10, 2.1.2, 12.1.1)"
- "build-cuda (3.11, 2.2.2, 12.1.1)"
- "build-cuda (3.11, 2.3.1, 12.1.1)"
- "build-cuda (3.11, 2.4.1, 12.1.1)"
- "build-cuda (3.12, 2.5.1, 12.1.1)"
#- "build-NGC"
- "build-pl (3.10, 2.1, 12.1.0)"
- "build-pl (3.11, 2.2, 12.1.0)"
- "build-pl (3.11, 2.3, 12.1.0)"
- "build-pl (3.11, 2.4, 12.1.0)"
- "build-pl (3.12, 2.5, 12.1.0)"
- "build-pl (3.10, 2.1, 12.1.1)"
- "build-pl (3.11, 2.2, 12.1.1)"
- "build-pl (3.11, 2.3, 12.1.1)"
- "build-pl (3.11, 2.4, 12.1.1)"
- "build-pl (3.12, 2.5, 12.1.1, true)"

# SECTION: lightning_fabric

Expand Down
45 changes: 18 additions & 27 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ jobs:
include:
# We only release one docker image per PyTorch version.
# Make sure the matrix here matches the one below.
- { python_version: "3.10", pytorch_version: "2.1", cuda_version: "12.1.0" }
- { python_version: "3.11", pytorch_version: "2.2", cuda_version: "12.1.0" }
- { python_version: "3.11", pytorch_version: "2.3", cuda_version: "12.1.0" }
- { python_version: "3.11", pytorch_version: "2.4", cuda_version: "12.1.0" }
- { python_version: "3.12", pytorch_version: "2.5", cuda_version: "12.1.0" }
- { python_version: "3.10", pytorch_version: "2.1", cuda_version: "12.1.1" }
- { python_version: "3.11", pytorch_version: "2.2", cuda_version: "12.1.1" }
- { python_version: "3.11", pytorch_version: "2.3", cuda_version: "12.1.1" }
- { python_version: "3.11", pytorch_version: "2.4", cuda_version: "12.1.1" }
- { python_version: "3.12", pytorch_version: "2.5", cuda_version: "12.1.1", latest: "true" }
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -65,23 +65,14 @@ jobs:
run: echo "RELEASE_VERSION=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
- name: Set tags
run: |
import os

repo = "pytorchlightning/pytorch_lightning"
ver = os.getenv('RELEASE_VERSION')
py_ver = "${{ matrix.python_version }}"
pt_ver = "${{ matrix.pytorch_version }}"
cuda_ver = "${{ matrix.cuda_version }}"
tags = [f"latest-py{py_ver}-torch{pt_ver}-cuda{cuda_ver}"]
if ver:
tags += [f"{ver}-py{py_ver}-torch{pt_ver}-cuda{cuda_ver}"]
if py_ver == '3.11' and pt_ver == '2.3' and cuda_ver == '12.1.0':
tags += ["latest"]

tags = [f"{repo}:{tag}" for tag in tags]
with open(os.getenv('GITHUB_ENV'), "a") as gh_env:
gh_env.write("DOCKER_TAGS=" + ",".join(tags))
shell: python
pip install -q -r .actions/requirements.txt
tags=$(python .actions/assistant.py generate_docker_tags \
--release_version="${{ env.RELEASE_VERSION }}" \
--python_version="${{ matrix.python_version }}" \
--torch_version="${{ matrix.pytorch_version }}" \
--cuda_version="${{ matrix.cuda_version }}" \
--add_latest="${{ matrix.latest || 'false' }}")
echo "DOCKER_TAGS=$tags" >> $GITHUB_ENV

- uses: docker/build-push-action@v6
with:
Expand All @@ -104,11 +95,11 @@ jobs:
include:
# These are the base images for PL release docker images.
# Make sure the matrix here matches the one above.
- { python_version: "3.10", pytorch_version: "2.1.2", cuda_version: "12.1.0" }
- { python_version: "3.11", pytorch_version: "2.2.2", cuda_version: "12.1.0" }
- { python_version: "3.11", pytorch_version: "2.3.1", cuda_version: "12.1.0" }
- { python_version: "3.11", pytorch_version: "2.4.1", cuda_version: "12.1.0" }
- { python_version: "3.12", pytorch_version: "2.5.1", cuda_version: "12.1.0" }
- { python_version: "3.10", pytorch_version: "2.1.2", cuda_version: "12.1.1" }
- { python_version: "3.11", pytorch_version: "2.2.2", cuda_version: "12.1.1" }
- { python_version: "3.11", pytorch_version: "2.3.1", cuda_version: "12.1.1" }
- { python_version: "3.11", pytorch_version: "2.4.1", cuda_version: "12.1.1" }
- { python_version: "3.12", pytorch_version: "2.5.1", cuda_version: "12.1.1" }
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
Expand Down
Loading