-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_run.sh
64 lines (51 loc) · 1.69 KB
/
test_run.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
#!/usr/bin/env bash
#docker rmi $(docker images -f "dangling=true" -q)
# Stop at first error
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
DOCKER_TAG="example-algorithm-preliminary-development-phase"
DOCKER_NOOP_VOLUME="${DOCKER_TAG}-volume"
INPUT_DIR="${SCRIPT_DIR}/test/input"
OUTPUT_DIR="${SCRIPT_DIR}/test/output"
MEM_LIMIT="30g"
MEM_SWAP_LIMIT="30g"
echo "=+= Cleaning up any earlier output"
if [ -d "$OUTPUT_DIR" ]; then
# Ensure permissions are setup correctly
# This allows for the Docker user to write to this location
rm -rf "${OUTPUT_DIR}"/*
chmod -f o+rwx "$OUTPUT_DIR"
else
mkdir --mode=o+rwx "$OUTPUT_DIR"
fi
echo "=+= (Re)build the container"
docker build "$SCRIPT_DIR" \
--platform=linux/amd64 \
--tag $DOCKER_TAG 2>&1
echo "=+= Doing a forward pass"
## Note the extra arguments that are passed here:
# '--network none'
# entails there is no internet connection
# 'gpus all'
# enables access to any GPUs present
# '--volume <NAME>:/tmp'
# is added because on Grand Challenge this directory cannot be used to store permanent files
docker volume create "$DOCKER_NOOP_VOLUME"
docker run --rm \
--platform=linux/amd64 \
--network="none" \
--cap-drop="ALL" \
--security-opt="no-new-privileges" \
--shm-size="128m" \
--pids-limit="256" \
--cpus 8 \
--memory="${MEM_LIMIT}" \
--memory-swap="${MEM_SWAP_LIMIT}" \
--gpus all \
--volume "$INPUT_DIR":/input \
--volume "$OUTPUT_DIR":/output \
--volume "$DOCKER_NOOP_VOLUME":/tmp \
$DOCKER_TAG
docker volume rm "$DOCKER_NOOP_VOLUME"
echo "=+= Wrote results to ${OUTPUT_DIR}"
echo "=+= Save this image for uploading via save.sh \"${DOCKER_TAG}\""