Skip to content

Commit 8ff0d76

Browse files
committed
modify script to build container image
1 parent 2392b88 commit 8ff0d76

File tree

5 files changed

+48
-33
lines changed

5 files changed

+48
-33
lines changed

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
HAS_LINT := $(shell command -v golangci-lint;)
22
COMMIT := v1beta1-$(shell git rev-parse --short=7 HEAD)
33
KATIB_REGISTRY := docker.io/kubeflowkatib
4+
CPU_ARCH ?= amd64
45

56
# Run tests
67
.PHONY: test
@@ -48,11 +49,12 @@ endif
4849
cd ./pkg/apis/manager/health && ./build.sh
4950

5051
# Build images for the Katib v1beta1 components.
51-
build: generate
52-
ifeq ($(and $(REGISTRY),$(TAG)),)
53-
$(error REGISTRY and TAG must be set. Usage: make build REGISTRY=<registry> TAG=<tag>)
52+
#build: generate
53+
build:
54+
ifeq ($(and $(REGISTRY),$(TAG),$(CPU_ARCH)),)
55+
$(error REGISTRY and TAG must be set. Usage: make build REGISTRY=<registry> TAG=<tag> CPU_ARCH=<cpu-architecture>)
5456
endif
55-
bash scripts/v1beta1/build.sh $(REGISTRY) $(TAG)
57+
bash scripts/v1beta1/build.sh $(REGISTRY) $(TAG) $(CPU_ARCH)
5658

5759
# Build and push Katib images from the latest master commit.
5860
push-latest: generate

docs/developer-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ see the following user guides:
1313
## Requirements
1414

1515
- [Go](https://golang.org/) (1.17 or later)
16-
- [Docker](https://docs.docker.com/) (17.05 or later)
16+
- [Docker](https://docs.docker.com/) (20.10 or later)
1717
- [Java](https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html) (8 or later)
1818
- [Python](https://www.python.org/) (3.9 or later)
1919
- [kustomize](https://kustomize.io/) (4.0.5 or later)

examples/v1beta1/trial-images/enas-cnn-cifar10/Dockerfile.cpu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM tensorflow/tensorflow:1.15.4-py3
1+
FROM tensorflow/tensorflow:2.7.0
22

33
ENV TARGET_DIR /opt/enas-cnn-cifar10
44

examples/v1beta1/trial-images/enas-cnn-cifar10/Dockerfile.gpu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM tensorflow/tensorflow:1.15.4-gpu-py3
1+
FROM tensorflow/tensorflow:2.7.0-gpu
22

33
ENV TARGET_DIR /opt/enas-cnn-cifar10
44

scripts/v1beta1/build.sh

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,29 @@ set -e
2121

2222
REGISTRY=$1
2323
TAG=$2
24+
ARCH=$3
2425

25-
if [[ -z "$REGISTRY" || -z "$TAG" ]]; then
26-
echo "Image registry and tag must be set"
27-
echo "Usage: $0 <image-registry> <image-tag>" 1>&2
26+
if [[ -z "$REGISTRY" || -z "$TAG" || -z "$ARCH" ]]; then
27+
echo "Image registry, tag and architecture must be set"
28+
echo "Usage: $0 <image-registry> <image-tag> <cpu-architecture>" 1>&2
2829
exit 1
2930
fi
3031

32+
SUPPORTED_CPU_ARCHS=$(docker buildx inspect | grep 'Platforms' | sed -e 's|Platforms: ||' -e 's|,||g' -e 's|linux/||g')
33+
function check_specified_cpu_arch() {
34+
for SUPPORTED_ARCH in $SUPPORTED_CPU_ARCHS; do \
35+
if [ $ARCH = $SUPPORTED_ARCH ]; then \
36+
return 0
37+
fi;
38+
done
39+
echo "CPU architecture '$ARCH' is not supported"
40+
echo "You can use '$SUPPORTED_CPU_ARCHS'"
41+
return 1
42+
}
43+
check_specified_cpu_arch
44+
3145
VERSION="v1beta1"
3246
CMD_PREFIX="cmd"
33-
MACHINE_ARCH=$(uname -m)
3447

3548
echo "Building images for Katib ${VERSION}..."
3649
echo "Image registry: ${REGISTRY}"
@@ -41,77 +54,77 @@ cd ${SCRIPT_ROOT}
4154

4255
# Katib core images
4356
echo -e "\nBuilding Katib controller image...\n"
44-
docker build -t ${REGISTRY}/katib-controller:${TAG} -f ${CMD_PREFIX}/katib-controller/${VERSION}/Dockerfile .
57+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/katib-controller:${TAG} -f ${CMD_PREFIX}/katib-controller/${VERSION}/Dockerfile .
4558

4659
echo -e "\nBuilding Katib DB manager image...\n"
47-
docker build -t ${REGISTRY}/katib-db-manager:${TAG} -f ${CMD_PREFIX}/db-manager/${VERSION}/Dockerfile .
60+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/katib-db-manager:${TAG} -f ${CMD_PREFIX}/db-manager/${VERSION}/Dockerfile .
4861

4962
# TODO (andreyvelich): Switch to ${CMD_PREFIX}/ui/${VERSION}/Dockerfile once old UI is deprecated.
5063
echo -e "\nBuilding Katib UI image...\n"
51-
docker build -t ${REGISTRY}/katib-ui:${TAG} -f ${CMD_PREFIX}/new-ui/${VERSION}/Dockerfile .
64+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/katib-ui:${TAG} -f ${CMD_PREFIX}/new-ui/${VERSION}/Dockerfile .
5265

5366
echo -e "\nBuilding Katib cert generator image...\n"
54-
docker build -t ${REGISTRY}/cert-generator:${TAG} -f ${CMD_PREFIX}/cert-generator/${VERSION}/Dockerfile .
67+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/cert-generator:${TAG} -f ${CMD_PREFIX}/cert-generator/${VERSION}/Dockerfile .
5568

5669
echo -e "\nBuilding file metrics collector image...\n"
57-
docker build -t ${REGISTRY}/file-metrics-collector:${TAG} -f ${CMD_PREFIX}/metricscollector/${VERSION}/file-metricscollector/Dockerfile .
70+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/file-metrics-collector:${TAG} -f ${CMD_PREFIX}/metricscollector/${VERSION}/file-metricscollector/Dockerfile .
5871

5972
echo -e "\nBuilding TF Event metrics collector image...\n"
60-
if [ $MACHINE_ARCH == "ppc64le" ]; then
61-
docker build -t ${REGISTRY}/tfevent-metrics-collector:${TAG} -f ${CMD_PREFIX}/metricscollector/${VERSION}/tfevent-metricscollector/Dockerfile.ppc64le .
73+
if [ $ARCH == "ppc64le" ]; then
74+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/tfevent-metrics-collector:${TAG} -f ${CMD_PREFIX}/metricscollector/${VERSION}/tfevent-metricscollector/Dockerfile.ppc64le .
6275
else
63-
docker build -t ${REGISTRY}/tfevent-metrics-collector:${TAG} -f ${CMD_PREFIX}/metricscollector/${VERSION}/tfevent-metricscollector/Dockerfile .
76+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/tfevent-metrics-collector:${TAG} -f ${CMD_PREFIX}/metricscollector/${VERSION}/tfevent-metricscollector/Dockerfile .
6477
fi
6578

6679
# Suggestion images
6780
echo -e "\nBuilding suggestion images..."
6881

6982
echo -e "\nBuilding hyperopt suggestion...\n"
70-
docker build -t ${REGISTRY}/suggestion-hyperopt:${TAG} -f ${CMD_PREFIX}/suggestion/hyperopt/${VERSION}/Dockerfile .
83+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/suggestion-hyperopt:${TAG} -f ${CMD_PREFIX}/suggestion/hyperopt/${VERSION}/Dockerfile .
7184

7285
echo -e "\nBuilding chocolate suggestion...\n"
73-
docker build -t ${REGISTRY}/suggestion-chocolate:${TAG} -f ${CMD_PREFIX}/suggestion/chocolate/${VERSION}/Dockerfile .
86+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/suggestion-chocolate:${TAG} -f ${CMD_PREFIX}/suggestion/chocolate/${VERSION}/Dockerfile .
7487

7588
echo -e "\nBuilding hyperband suggestion...\n"
76-
docker build -t ${REGISTRY}/suggestion-hyperband:${TAG} -f ${CMD_PREFIX}/suggestion/hyperband/${VERSION}/Dockerfile .
89+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/suggestion-hyperband:${TAG} -f ${CMD_PREFIX}/suggestion/hyperband/${VERSION}/Dockerfile .
7790

7891
echo -e "\nBuilding skopt suggestion...\n"
79-
docker build -t ${REGISTRY}/suggestion-skopt:${TAG} -f ${CMD_PREFIX}/suggestion/skopt/${VERSION}/Dockerfile .
92+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/suggestion-skopt:${TAG} -f ${CMD_PREFIX}/suggestion/skopt/${VERSION}/Dockerfile .
8093

8194
echo -e "\nBuilding goptuna suggestion...\n"
82-
docker build -t ${REGISTRY}/suggestion-goptuna:${TAG} -f ${CMD_PREFIX}/suggestion/goptuna/${VERSION}/Dockerfile .
95+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/suggestion-goptuna:${TAG} -f ${CMD_PREFIX}/suggestion/goptuna/${VERSION}/Dockerfile .
8396

8497
echo -e "\nBuilding optuna suggestion...\n"
85-
docker build -t ${REGISTRY}/suggestion-optuna:${TAG} -f ${CMD_PREFIX}/suggestion/optuna/${VERSION}/Dockerfile .
98+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/suggestion-optuna:${TAG} -f ${CMD_PREFIX}/suggestion/optuna/${VERSION}/Dockerfile .
8699

87100
echo -e "\nBuilding ENAS suggestion...\n"
88-
docker build -t ${REGISTRY}/suggestion-enas:${TAG} -f ${CMD_PREFIX}/suggestion/nas/enas/${VERSION}/Dockerfile .
101+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/suggestion-enas:${TAG} -f ${CMD_PREFIX}/suggestion/nas/enas/${VERSION}/Dockerfile .
89102

90103
echo -e "\nBuilding DARTS suggestion...\n"
91-
docker build -t ${REGISTRY}/suggestion-darts:${TAG} -f ${CMD_PREFIX}/suggestion/nas/darts/${VERSION}/Dockerfile .
104+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/suggestion-darts:${TAG} -f ${CMD_PREFIX}/suggestion/nas/darts/${VERSION}/Dockerfile .
92105

93106
# Early stopping images
94107
echo -e "\nBuilding early stopping images...\n"
95108

96109
echo -e "\nBuilding median stopping rule...\n"
97-
docker build -t ${REGISTRY}/earlystopping-medianstop:${TAG} -f ${CMD_PREFIX}/earlystopping/medianstop/${VERSION}/Dockerfile .
110+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/earlystopping-medianstop:${TAG} -f ${CMD_PREFIX}/earlystopping/medianstop/${VERSION}/Dockerfile .
98111

99112
# Training container images
100113
echo -e "\nBuilding training container images..."
101114

102115
echo -e "\nBuilding mxnet mnist training container example...\n"
103-
docker build -t ${REGISTRY}/mxnet-mnist:${TAG} -f examples/${VERSION}/trial-images/mxnet-mnist/Dockerfile .
116+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/mxnet-mnist:${TAG} -f examples/${VERSION}/trial-images/mxnet-mnist/Dockerfile .
104117

105118
echo -e "\nBuilding PyTorch mnist training container example...\n"
106-
docker build -t ${REGISTRY}/pytorch-mnist:${TAG} -f examples/${VERSION}/trial-images/pytorch-mnist/Dockerfile .
119+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/pytorch-mnist:${TAG} -f examples/${VERSION}/trial-images/pytorch-mnist/Dockerfile .
107120

108121
echo -e "\nBuilding Keras CIFAR-10 CNN training container example for ENAS with GPU support...\n"
109-
docker build -t ${REGISTRY}/enas-cnn-cifar10-gpu:${TAG} -f examples/${VERSION}/trial-images/enas-cnn-cifar10/Dockerfile.gpu .
122+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/enas-cnn-cifar10-gpu:${TAG} -f examples/${VERSION}/trial-images/enas-cnn-cifar10/Dockerfile.gpu .
110123

111124
echo -e "\nBuilding Keras CIFAR-10 CNN training container example for ENAS with CPU support...\n"
112-
docker build -t ${REGISTRY}/enas-cnn-cifar10-cpu:${TAG} -f examples/${VERSION}/trial-images/enas-cnn-cifar10/Dockerfile.cpu .
125+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/enas-cnn-cifar10-cpu:${TAG} -f examples/${VERSION}/trial-images/enas-cnn-cifar10/Dockerfile.cpu .
113126

114127
echo -e "\nBuilding PyTorch CIFAR-10 CNN training container example for DARTS...\n"
115-
docker build -t ${REGISTRY}/darts-cnn-cifar10:${TAG} -f examples/${VERSION}/trial-images/darts-cnn-cifar10/Dockerfile .
128+
docker buildx build --platform linux/$ARCH -t ${REGISTRY}/darts-cnn-cifar10:${TAG} -f examples/${VERSION}/trial-images/darts-cnn-cifar10/Dockerfile .
116129

117130
echo -e "\nAll Katib images with ${TAG} tag have been built successfully!\n"

0 commit comments

Comments
 (0)