Skip to content

Commit ba8c268

Browse files
udaij12agunapal
andauthoredSep 17, 2024··
adding graviton docker image release (#3313)
* adding graviton docker image * testing multiplatform ci * testing multiplatform ci * testing multiplatform ci * adding new builder * removing arm * removing arm * testing arm * tests * testing driver command * testing driver command * testing on newer instance * testing on newer instance * testing newer * rm command * changing platform * testing only amd * testing both arch * testing both arch * testing both * remove builder * remove builder * adding amd * building cache * cache 3 * cache 4 * cache 4 * final test * reverting temp changes * testing official release * testing official release * testing official release * adding kserve changes * kserve nightly --------- Co-authored-by: Ankith Gunapal <agunapal@ischool.Berkeley.edu>
1 parent 646862e commit ba8c268

8 files changed

+47
-27
lines changed
 

‎.github/workflows/docker-nightly-build.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name: Push Docker Nightly
22

33
on:
4-
# run every day at 1:15pm
4+
# Run every day at 1:15pm
55
schedule:
66
- cron: "15 13 * * *"
77
workflow_dispatch:
8+
89
jobs:
910
nightly:
1011
runs-on: [self-hosted, ci-gpu]
@@ -32,12 +33,14 @@ jobs:
3233
- name: Push Docker Nightly
3334
run: |
3435
cd docker
36+
sudo apt-get update
37+
docker buildx use multibuilder
3538
python docker_nightly.py --cleanup
3639
- name: Push KServe Docker Nightly
3740
run: |
3841
cd kubernetes/kserve
42+
docker buildx use multibuilder
3943
python docker_nightly.py --cleanup
40-
4144
- name: Open issue on failure
4245
if: ${{ failure() && github.event_name == 'schedule' }}
4346
uses: dacbd/create-issue-action@v1

‎.github/workflows/official_release_docker.yml

+2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ jobs:
4242
if: github.event.inputs.upload_docker == 'yes'
4343
run: |
4444
cd docker
45+
docker buildx use multibuilder
4546
python build_upload_release.py --cleanup
4647
- name: Build & Upload pytorch/torchserve-kfs Docker images
4748
if: github.event.inputs.upload_kfs == 'yes'
4849
run: |
4950
cd kubernetes/kserve
51+
docker buildx use multibuilder
5052
python build_upload_release.py --cleanup

‎docker/build_image.sh

+17-6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ BUILD_NIGHTLY=false
1818
BUILD_FROM_SRC=false
1919
LOCAL_CHANGES=true
2020
PYTHON_VERSION=3.9
21+
ARCH="linux/arm64,linux/amd64"
22+
MULTI=false
2123

2224
for arg in "$@"
2325
do
@@ -101,6 +103,10 @@ do
101103
BUILD_CPP=true
102104
shift
103105
;;
106+
-m|--multi)
107+
MULTI=true
108+
shift
109+
;;
104110
-n|--nightly)
105111
BUILD_NIGHTLY=true
106112
shift
@@ -214,12 +220,17 @@ then
214220
fi
215221
fi
216222

217-
if [ "${BUILD_TYPE}" == "production" ]
218-
then
219-
DOCKER_BUILDKIT=1 docker build --file Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg USE_CUDA_VERSION="${CUDA_VERSION}" --build-arg PYTHON_VERSION="${PYTHON_VERSION}"\
220-
--build-arg BUILD_NIGHTLY="${BUILD_NIGHTLY}" --build-arg BRANCH_NAME="${BRANCH_NAME}" --build-arg REPO_URL="${REPO_URL}" --build-arg BUILD_FROM_SRC="${BUILD_FROM_SRC}"\
221-
--build-arg LOCAL_CHANGES="${LOCAL_CHANGES}" -t "${DOCKER_TAG}" --target production-image ../
222-
elif [ "${BUILD_TYPE}" == "ci" ]
223+
if [ "${BUILD_TYPE}" == "production" ]; then
224+
if [ "${MULTI}" == "true" ]; then
225+
DOCKER_BUILDKIT=1 docker buildx build --file Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg USE_CUDA_VERSION="${CUDA_VERSION}" --build-arg PYTHON_VERSION="${PYTHON_VERSION}"\
226+
--build-arg BUILD_NIGHTLY="${BUILD_NIGHTLY}" --build-arg BRANCH_NAME="${BRANCH_NAME}" --build-arg REPO_URL="${REPO_URL}" --build-arg BUILD_FROM_SRC="${BUILD_FROM_SRC}"\
227+
--build-arg LOCAL_CHANGES="${LOCAL_CHANGES}" -t "${DOCKER_TAG}" --platform "${ARCH}" --target production-image ../ --push
228+
else
229+
DOCKER_BUILDKIT=1 docker buildx build --file Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg USE_CUDA_VERSION="${CUDA_VERSION}" --build-arg PYTHON_VERSION="${PYTHON_VERSION}"\
230+
--build-arg BUILD_NIGHTLY="${BUILD_NIGHTLY}" --build-arg BRANCH_NAME="${BRANCH_NAME}" --build-arg REPO_URL="${REPO_URL}" --build-arg BUILD_FROM_SRC="${BUILD_FROM_SRC}"\
231+
--build-arg LOCAL_CHANGES="${LOCAL_CHANGES}" -t "${DOCKER_TAG}" --target production-image ../ --load
232+
fi
233+
elif [ "${BUILD_TYPE}" == "ci" ];
223234
then
224235
DOCKER_BUILDKIT=1 docker build --file Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg USE_CUDA_VERSION="${CUDA_VERSION}" --build-arg PYTHON_VERSION="${PYTHON_VERSION}"\
225236
--build-arg BUILD_NIGHTLY="${BUILD_NIGHTLY}" --build-arg BRANCH_NAME="${BRANCH_NAME}" --build-arg REPO_URL="${REPO_URL}" --build-arg BUILD_FROM_SRC="${BUILD_FROM_SRC}"\

‎docker/build_upload_release.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
organization = args.organization
3232

3333
# Upload pytorch/torchserve docker binaries
34-
try_and_handle(f"./build_image.sh -t {organization}/torchserve:latest", dry_run)
34+
try_and_handle(f"./build_image.sh -m -t {organization}/torchserve:latest", dry_run)
3535
try_and_handle(
3636
f"./build_image.sh -g -cv cu121 -t {organization}/torchserve:latest-gpu",
3737
dry_run,
@@ -44,14 +44,17 @@
4444
f"./build_image.sh -bt dev -g -cv cu121 -cpp -t {organization}/torchserve:latest-cpp-dev-gpu",
4545
dry_run,
4646
)
47+
4748
try_and_handle(
48-
f"docker tag {organization}/torchserve:latest {organization}/torchserve:latest-cpu",
49+
f"docker buildx imagetools create --tag {organization}/torchserve:latest-cpu {organization}/torchserve:latest",
4950
dry_run,
5051
)
52+
5153
try_and_handle(
52-
f"docker tag {organization}/torchserve:latest {organization}/torchserve:{check_ts_version()}-cpu",
54+
f"docker buildx imagetools create --tag {organization}/torchserve:{check_ts_version()}-cpu {organization}/torchserve:latest",
5355
dry_run,
5456
)
57+
5558
try_and_handle(
5659
f"docker tag {organization}/torchserve:latest-gpu {organization}/torchserve:{check_ts_version()}-gpu",
5760
dry_run,
@@ -66,12 +69,9 @@
6669
)
6770

6871
for image in [
69-
f"{organization}/torchserve:latest",
70-
f"{organization}/torchserve:latest-cpu",
7172
f"{organization}/torchserve:latest-gpu",
7273
f"{organization}/torchserve:latest-cpp-dev-cpu",
7374
f"{organization}/torchserve:latest-cpp-dev-gpu",
74-
f"{organization}/torchserve:{check_ts_version()}-cpu",
7575
f"{organization}/torchserve:{check_ts_version()}-gpu",
7676
f"{organization}/torchserve:{check_ts_version()}-cpp-dev-cpu",
7777
f"{organization}/torchserve:{check_ts_version()}-cpp-dev-gpu",

‎docker/docker_nightly.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
cpp_dev_gpu_version = f"{project}:cpp-dev-gpu-{get_nightly_version()}"
4040

4141
# Build Nightly images and append the date in the name
42-
try_and_handle(f"./build_image.sh -n -t {organization}/{cpu_version}", dry_run)
42+
try_and_handle(f"./build_image.sh -m -n -t {organization}/{cpu_version}", dry_run)
4343
try_and_handle(
4444
f"./build_image.sh -g -cv cu121 -n -t {organization}/{gpu_version}",
4545
dry_run,
@@ -54,18 +54,17 @@
5454
)
5555

5656
# Push Nightly images to official PyTorch Dockerhub account
57-
try_and_handle(f"docker push {organization}/{cpu_version}", dry_run)
5857
try_and_handle(f"docker push {organization}/{gpu_version}", dry_run)
5958
try_and_handle(f"docker push {organization}/{cpp_dev_cpu_version}", dry_run)
6059
try_and_handle(f"docker push {organization}/{cpp_dev_gpu_version}", dry_run)
6160

6261
# Tag nightly images with latest
6362
try_and_handle(
64-
f"docker tag {organization}/{cpu_version} {organization}/{project}:latest-cpu",
63+
f"docker buildx imagetools create --tag {organization}/{project}:latest-cpu {organization}/{cpu_version}",
6564
dry_run,
6665
)
6766
try_and_handle(
68-
f"docker tag {organization}/{gpu_version} {organization}/{project}:latest-gpu",
67+
f"docker buildx imagetools create --tag {organization}/{project}:latest-gpu {organization}/{gpu_version}",
6968
dry_run,
7069
)
7170
try_and_handle(
@@ -78,8 +77,6 @@
7877
)
7978

8079
# Push images with latest tag
81-
try_and_handle(f"docker push {organization}/{project}:latest-cpu", dry_run)
82-
try_and_handle(f"docker push {organization}/{project}:latest-gpu", dry_run)
8380
try_and_handle(f"docker push {organization}/{project}:latest-cpp-dev-cpu", dry_run)
8481
try_and_handle(f"docker push {organization}/{project}:latest-cpp-dev-gpu", dry_run)
8582

‎kubernetes/kserve/build_image.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ BASE_IMAGE="pytorch/torchserve:latest-cpu"
66
DOCKER_FILE="Dockerfile"
77
BUILD_NIGHTLY=false
88
USE_CUSTOM_TAG=false
9+
ARCH="linux/arm64,linux/amd64"
10+
MULTI=false
911

1012
for arg in "$@"
1113
do
@@ -38,6 +40,10 @@ do
3840
shift
3941
shift
4042
;;
43+
-m|--multi)
44+
MULTI=true
45+
shift
46+
;;
4147
esac
4248
done
4349

@@ -57,4 +63,8 @@ fi
5763
cp ../../frontend/server/src/main/resources/proto/*.proto .
5864
cp -r ../../third_party .
5965

60-
DOCKER_BUILDKIT=1 docker build --file "$DOCKER_FILE" --build-arg BASE_IMAGE=$BASE_IMAGE -t "$DOCKER_TAG" .
66+
if [ "${MULTI}" == "true" ]; then
67+
DOCKER_BUILDKIT=1 docker buildx build --file "$DOCKER_FILE" --build-arg BASE_IMAGE=$BASE_IMAGE --platform "${ARCH}" -t "$DOCKER_TAG" --push
68+
else
69+
DOCKER_BUILDKIT=1 docker buildx build --file "$DOCKER_FILE" --build-arg BASE_IMAGE=$BASE_IMAGE -t "$DOCKER_TAG" --load
70+
fi

‎kubernetes/kserve/build_upload_release.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
organization = args.organization
3232

3333
try_and_handle(
34-
f"./build_image.sh -t {organization}/torchserve-kfs:{check_ts_version()}",
34+
f"./build_image.sh -m -t {organization}/torchserve-kfs:{check_ts_version()}",
3535
dry_run,
3636
)
3737
try_and_handle(
@@ -40,7 +40,6 @@
4040
)
4141

4242
for image in [
43-
f"{organization}/torchserve-kfs:{check_ts_version()}",
4443
f"{organization}/torchserve-kfs:{check_ts_version()}-gpu",
4544
]:
4645
try_and_handle(f"docker push {image}", dry_run)

‎kubernetes/kserve/docker_nightly.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,18 @@
3737
gpu_version = f"{project}:gpu-{get_nightly_version()}"
3838

3939
# Build Nightly images and append the date in the name
40-
try_and_handle(f"./build_image.sh -n -t {organization}/{cpu_version}", dry_run)
40+
try_and_handle(f"./build_image.sh -m -n -t {organization}/{cpu_version}", dry_run)
4141
try_and_handle(
4242
f"./build_image.sh -g -n -t {organization}/{gpu_version}",
4343
dry_run,
4444
)
4545

4646
# Push Nightly images to official PyTorch Dockerhub account
47-
try_and_handle(f"docker push {organization}/{cpu_version}", dry_run)
4847
try_and_handle(f"docker push {organization}/{gpu_version}", dry_run)
4948

5049
# Tag nightly images with latest
5150
try_and_handle(
52-
f"docker tag {organization}/{cpu_version} {organization}/{project}:latest-cpu",
51+
f"docker buildx imagetools create --tag {organization}/{project}:latest-cpu {organization}/{cpu_version}",
5352
dry_run,
5453
)
5554
try_and_handle(
@@ -58,7 +57,6 @@
5857
)
5958

6059
# Push images with latest tag
61-
try_and_handle(f"docker push {organization}/{project}:latest-cpu", dry_run)
6260
try_and_handle(f"docker push {organization}/{project}:latest-gpu", dry_run)
6361

6462
# Cleanup built images

0 commit comments

Comments
 (0)
Please sign in to comment.