-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcR-ck-docker.sh
executable file
·58 lines (49 loc) · 1.75 KB
/
cR-ck-docker.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
#!/bin/bash
# Runs a container from the given docker image. ci images only.
# Stores the last image for later retrieval using the 'last' parameter
script_dir=$(dirname $0)
last_image_file=$script_dir/data/last_ck_image
wd=$HOME
touch $last_image_file
test_tag=`cat $last_image_file`
if [ $# -eq 0 ]; then
echo "Usage: cR-ck-docker <ck_docker_tag|last> [once]"
echo "- to see a list of images, run: 'docker image list | grep rocm/composable_kernel'"
if [ -n "$test_tag" ]; then
echo "- run 'cR-ck-docker last' to run container '$test_tag' again"
fi
echo "- to prevent storing this image, add 'once' after the tag name"
exit 1
fi
if [ ${1,,} = "last" ]; then
use_last=1
else
test_tag=$1
fi
if [ -n "$test_tag" ]; then
image_grep=`docker image list | grep $test_tag`
fi
if [ -n "$image_grep" ]; then
ck_tag=$test_tag
echo "Running container '$ck_tag'"
else
if [ $use_last ]; then
echo "Error: file '$last_image_file' does not contain a valid image name ('$test_tag')"
else
echo "Error: docker image '$test_tag' was not found"
fi
exit 1
fi
if [ $# -lt 2 ]; then # TODO: check for 'once'
echo "$ck_tag" > $last_image_file
fi
SU=
if [ "$HOSTNAME" = shemp ]; then
SU=sudo
fi
# get a random name ala https://devops.stackexchange.com/questions/9810/how-to-get-the-next-friendly-name-that-docker-will-assign-to-the-container-it-wi
DKR_NAME=$(curl -s https://frightanic.com/goodies_content/docker-names.php)
# launch the container
if ! ($SU docker run -w $wd/repos -v $wd:$wd -it --name $DKR_NAME --hostname $DKR_NAME --privileged --device=/dev/kfd --device=/dev/dri rocm/composable_kernel:$ck_tag); then
$SU docker run -w $wd -v $wd:$wd -it --name $DKR_NAME --hostname $DKR_NAME --privileged --device=/dev/kfd --device=/dev/dri rocm/composable_kernel:$ck_tag
fi