-
Notifications
You must be signed in to change notification settings - Fork 66
/
docker_build.sh
executable file
·45 lines (37 loc) · 1.25 KB
/
docker_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
#!/bin/bash
# usage: ./docker_build.sh 20.04-cu11.0.3
# echo "argv: $1"
UBUNTU_VERSION=`echo $1 | awk -F '-cu' '{print $1}'`
CUDA_VERSION=`echo $1 | awk -F '-cu' '{print $2}'`
echo "ubuntu version:${UBUNTU_VERSION},cuda version:${CUDA_VERSION}"
# check ubuntu version
if [[(${UBUNTU_VERSION} != "18.04") && (${UBUNTU_VERSION} != "20.04") && (${UBUNTU_VERSION} != "22.04") && (${UBUNTU_VERSION} != "24.04")]];then
echo "Invalid ubuntu version:${UBUNTU_VERSION}"
exit -1
fi
# pull base image (ubuntu/cuda)
if [[("${CUDA_VERSION}" == "")]];then
BASE_IMAGE=ubuntu:${UBUNTU_VERSION}
else
BASE_IMAGE=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
fi
echo ${BASE_IMAGE}
docker pull ${BASE_IMAGE}
if [[ $? != 0 ]]; then
echo "Failed to pull docker image '${BASE_IMAGE}'"
exit -2
fi
# build ubuntu-desktop image
if [[("${CUDA_VERSION}" == "")]];then
DOCKER_TAG=${UBUNTU_VERSION}
else
DOCKER_TAG=${UBUNTU_VERSION}-cu${CUDA_VERSION}
fi
docker build ubuntu-desktop --file ubuntu-desktop/${UBUNTU_VERSION}/Dockerfile \
--build-arg BASE_IMAGE=${BASE_IMAGE} \
--tag ubuntu-desktop:${DOCKER_TAG}
if [[ $? != 0 ]]; then
echo "Failed to build docker image 'ubuntu-desktop:${DOCKER_TAG}'"
exit -3
fi
exit 0