This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.sh
executable file
·70 lines (56 loc) · 1.82 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
trap ctrl_c INT
function ctrl_c() {
echo "Requested to stop."
exit 1
}
set -e
PREFIX="awsdeepracercommunity"
ARCH="cpu gpu cpu-intel"
while getopts ":2fa:p:" opt; do
case $opt in
2)
OPT_SECOND_STAGE_ONLY="OPT_SECOND_STAGE_ONLY"
;;
p)
PREFIX="$OPTARG"
;;
a)
ARCH="$OPTARG"
;;
f)
OPT_NOCACHE="--no-cache"
;;
\?)
echo "Invalid option -$OPTARG" >&2
exit 1
;;
esac
done
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
cd $DIR
VERSION=$(cat VERSION)
echo "Preparing docker images for [$ARCH]"
TF_VER="tensorflow==2.13.1\ntensorflow-probability==0.21.0"
## First stage
if [[ -z "$OPT_SECOND_STAGE_ONLY" ]]; then
for arch in $ARCH; do
if [[ "$arch" == "gpu" ]]; then
docker buildx build $OPT_NOCACHE . -t $PREFIX/sagemaker-tensorflow-container:$VERSION-$arch -f docker/primary/Dockerfile.gpu \
--build-arg TF_VER=$TF_VER
elif [[ "$arch" == "cpu" ]]; then
docker buildx build $OPT_NOCACHE . -t $PREFIX/sagemaker-tensorflow-container:$VERSION-$arch -f docker/primary/Dockerfile.cpu \
--build-arg TF_VER=$TF_VER
elif [[ "$arch" == "cpu-intel" ]]; then
TF_VER='intel-tensorflow==2.13.0\ntensorflow-probability==0.21.0'
docker buildx build $OPT_NOCACHE . -t $PREFIX/sagemaker-tensorflow-container:$VERSION-$arch -f docker/primary/Dockerfile.cpu \
--build-arg TF_VER="$TF_VER"
fi
done
fi
cd $DIR
## Second stage
for arch in $ARCH; do
docker buildx build $OPT_NOCACHE -f docker/secondary/Dockerfile -t $PREFIX/deepracer-sagemaker:$VERSION-$arch . --build-arg version=$VERSION --build-arg arch=$arch --build-arg prefix=$PREFIX --build-arg IMG_VERSION=$VERSION
done
set +e