-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·38 lines (33 loc) · 829 Bytes
/
run
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
#!/bin/bash
set -e
mlgpus() {
A=(/proc/driver/nvidia/gpus/*)
if [ -e "${A[0]}" ]
then echo "${#A[*]}"
else echo "0"
fi
}
export MLGPUS=${MLGPUS:-$(mlgpus)}
export DATA=${DATA:-$(readlink -f data)} # user can symlink a custom path
export DATA=${DATA:-/data}
ARGS=(
--network=host
--mount=type=bind,source="$PWD",destination=/src
--mount=type=bind,source="$DATA",destination=/data
--env=TRANSFORMERS_CACHE=/data/cache/huggingface/transformers
--env=HF_DATASETS_CACHE=/data/cache/huggingface/datasets
--env=LANG
--workdir=/src
)
if [ "$MLGPUS" -gt 0 ]
then
ARGS=("${ARGS[@]}" --runtime=nvidia)
fi
[ -t 0 ] && ARGS=(-ti "${ARGS[@]}")
case "$1" in
--build)
docker build docker --tag rnd-html
shift
;;
esac
docker run --rm "${ARGS[@]}" rnd-html "$@"