-
Notifications
You must be signed in to change notification settings - Fork 491
Expand file tree
/
Copy pathrun_docker.sh
More file actions
executable file
·59 lines (52 loc) · 1.48 KB
/
run_docker.sh
File metadata and controls
executable file
·59 lines (52 loc) · 1.48 KB
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
#!/bin/bash
# obtain directory paths
dir_curr=`pwd`
dir_temp="${dir_curr}-minimal"
# create a minimal code directory
./scripts/create_minimal.sh ${dir_curr} ${dir_temp}
cd ${dir_temp}
# default arguments
nb_gpus=1
# parse arguments passed from the command line
py_script="$1"
shift
extra_args=""
for i in "$@"
do
case "$i" in
-n=*|--nb_gpus=*)
nb_gpus="${i#*=}"
shift
;;
*)
# unknown option
extra_args="${extra_args} ${i}"
shift
;;
esac
done
extra_args_path=`python utils/get_path_args.py docker ${py_script} path.conf`
extra_args="${extra_args} ${extra_args_path}"
echo ${extra_args} > extra_args
echo "Python script: ${py_script}"
echo "Data directory: ${dir_data}"
echo "# of GPUs: ${nb_gpus}"
echo "extra arguments: ${extra_args}"
# create temporary directory for log & model
dir_temp_log=`mktemp -d`
dir_temp_model=`mktemp -d`
dir_temp_data=`python utils/get_data_dir.py ${py_script} path.conf`
# enter the docker environment
cp -v ${py_script} main.py
idle_gpus=`python utils/get_idle_gpus.py ${nb_gpus}`
NV_GPU="${idle_gpus}" nvidia-docker run -it --rm --hostname=local-env \
--env SEVEN_HTTP_FORWARD_PORT= --env NB_GPUS=${nb_gpus} --network=host \
-v ${dir_temp}:/opt/ml/env \
-v ${dir_temp_log}:/opt/ml/log \
-v ${dir_temp_model}:/opt/ml/model \
-v ${dir_temp_data}:/opt/ml/data \
-w /opt/ml/env \
docker.oa.com/g_tfplus/horovod:python3.5 bash
# return to the main directory
rm -rf ${dir_temp_log} ${dir_temp_model}
cd ${dir_curr}