From cda7a6f04adb48e68d51b1e0785e797564ba7b43 Mon Sep 17 00:00:00 2001 From: tastelikefeet <58414341+tastelikefeet@users.noreply.github.com> Date: Wed, 23 Oct 2024 15:18:40 +0800 Subject: [PATCH 1/2] Update docker scripts (#1044) --- .github/workflows/docker-image.yml | 8 +++--- docker/build_image.py | 42 +++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 9845202f..6d20383d 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -8,16 +8,16 @@ on: required: true default: 'build' modelscope_branch: - description: 'ModelScope branch to build from' + description: 'ModelScope branch to build from(release/x.xx)' required: true image_type: - description: 'The image type to build' + description: 'The image type to build(cpu/gpu/llm)' required: true modelscope_version: - description: 'ModelScope version to use' + description: 'ModelScope version to use(x.xx.x)' required: true swift_branch: - description: 'SWIFT branch to use' + description: 'SWIFT branch to use(release/x.xx)' required: true other_params: description: 'Other params in --xxx xxx' diff --git a/docker/build_image.py b/docker/build_image.py index 42747686..53a2e936 100644 --- a/docker/build_image.py +++ b/docker/build_image.py @@ -1,9 +1,12 @@ import argparse import os +from datetime import datetime from typing import Any docker_registry = os.environ['DOCKER_REGISTRY'] assert docker_registry, 'You must pass a valid DOCKER_REGISTRY' +timestamp = datetime.now() +formatted_time = timestamp.strftime('%Y-%m-%d-%H:%M:%S') class Builder: @@ -85,12 +88,16 @@ class BaseCPUImageBuilder(Builder): return content def build(self): - image_tag = f'{docker_registry}:ubuntu{self.args.ubuntu_version}-torch{self.args.torch_version}-base' + image_tag = ( + f'{docker_registry}:ubuntu{self.args.ubuntu_version}-{self.args.python_tag}-' + f'torch{self.args.torch_version}-base') return os.system( f'DOCKER_BUILDKIT=0 docker build -t {image_tag} -f Dockerfile .') def push(self): - image_tag = f'{docker_registry}:ubuntu{self.args.ubuntu_version}-torch{self.args.torch_version}-base' + image_tag = ( + f'{docker_registry}:ubuntu{self.args.ubuntu_version}-{self.args.python_tag}-' + f'torch{self.args.torch_version}-base') return os.system(f'docker push {image_tag}') @@ -110,14 +117,14 @@ class BaseGPUImageBuilder(Builder): def build(self) -> int: image_tag = ( - f'{docker_registry}:ubuntu{self.args.ubuntu_version}-cuda{self.args.cuda_version}-' + f'{docker_registry}:ubuntu{self.args.ubuntu_version}-cuda{self.args.cuda_version}-{self.args.python_tag}-' f'torch{self.args.torch_version}-tf{self.args.tf_version}-base') return os.system( f'DOCKER_BUILDKIT=0 docker build -t {image_tag} -f Dockerfile .') def push(self): image_tag = ( - f'{docker_registry}:ubuntu{self.args.ubuntu_version}-cuda{self.args.cuda_version}-' + f'{docker_registry}:ubuntu{self.args.ubuntu_version}-cuda{self.args.cuda_version}-{self.args.python_tag}-' f'torch{self.args.torch_version}-tf{self.args.tf_version}-base') return os.system(f'docker push {image_tag}') @@ -129,7 +136,9 @@ class CPUImageBuilder(Builder): version_args = ( f'{self.args.torch_version} {self.args.torchvision_version} ' f'{self.args.torchaudio_version}') - base_image = f'{docker_registry}:ubuntu{self.args.ubuntu_version}-torch{self.args.torch_version}-base' + base_image = ( + f'{docker_registry}:ubuntu{self.args.ubuntu_version}-{self.args.python_tag}' + f'-torch{self.args.torch_version}-base') extra_content = """\nRUN pip install adaseq\nRUN pip install pai-easycv""" with open('docker/Dockerfile.ubuntu', 'r') as f: @@ -155,6 +164,13 @@ class CPUImageBuilder(Builder): f'{docker_registry}:ubuntu{self.args.ubuntu_version}-{self.args.python_tag}-' f'torch{self.args.torch_version}-{self.args.modelscope_version}-test' ) + ret = os.system(f'docker push {image_tag}') + if ret != 0: + return ret + image_tag = ( + f'{docker_registry}:ubuntu{self.args.ubuntu_version}-{self.args.python_tag}-' + f'torch{self.args.torch_version}-{self.args.modelscope_version}-{formatted_time}-test' + ) return os.system(f'docker push {image_tag}') @@ -168,7 +184,7 @@ class GPUImageBuilder(Builder): f'{self.args.vllm_version} {self.args.lmdeploy_version} {self.args.autogptq_version}' ) base_image = ( - f'{docker_registry}:ubuntu{self.args.ubuntu_version}-cuda{self.args.cuda_version}-' + f'{docker_registry}:ubuntu{self.args.ubuntu_version}-cuda{self.args.cuda_version}-{self.args.python_tag}-' f'torch{self.args.torch_version}-tf{self.args.tf_version}-base') with open('docker/Dockerfile.ubuntu', 'r') as f: content = f.read() @@ -193,6 +209,13 @@ class GPUImageBuilder(Builder): f'{docker_registry}:ubuntu{self.args.ubuntu_version}-cuda{self.args.cuda_version}-' f'{self.args.python_tag}-torch{self.args.torch_version}-tf{self.args.tf_version}-' f'{self.args.modelscope_version}-test') + ret = os.system(f'docker push {image_tag}') + if ret != 0: + return ret + image_tag = ( + f'{docker_registry}:ubuntu{self.args.ubuntu_version}-cuda{self.args.cuda_version}-' + f'{self.args.python_tag}-torch{self.args.torch_version}-tf{self.args.tf_version}-' + f'{self.args.modelscope_version}-{formatted_time}-test') return os.system(f'docker push {image_tag}') @@ -249,6 +272,13 @@ class LLMImageBuilder(Builder): f'{docker_registry}:ubuntu{self.args.ubuntu_version}-cuda{self.args.cuda_version}-' f'{self.args.python_tag}-torch{self.args.torch_version}-{self.args.modelscope_version}-LLM-test' ) + ret = os.system(f'docker push {image_tag}') + if ret != 0: + return ret + image_tag = ( + f'{docker_registry}:ubuntu{self.args.ubuntu_version}-cuda{self.args.cuda_version}-' + f'{self.args.python_tag}-torch{self.args.torch_version}-' + f'{self.args.modelscope_version}-LLM-{formatted_time}-test') return os.system(f'docker push {image_tag}') From 134fe72f06506953768a84af728d560a3bbc0389 Mon Sep 17 00:00:00 2001 From: "Xingjun.Wang" Date: Wed, 23 Oct 2024 16:25:53 +0800 Subject: [PATCH 2/2] hotfix for datasets 3.0.2 (#1046) --- requirements/datasets.txt | 2 +- requirements/framework.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements/datasets.txt b/requirements/datasets.txt index b290664e..d20154e1 100644 --- a/requirements/datasets.txt +++ b/requirements/datasets.txt @@ -1,6 +1,6 @@ addict attrs -datasets>=3.0.0 +datasets>=3.0.0,<=3.0.1 einops oss2 Pillow diff --git a/requirements/framework.txt b/requirements/framework.txt index dabab41f..9aa4c045 100644 --- a/requirements/framework.txt +++ b/requirements/framework.txt @@ -1,6 +1,6 @@ addict attrs -datasets>=3.0.0 +datasets>=3.0.0,<=3.0.1 einops oss2 Pillow