forked from TangYiChing/PathDSP
-
Notifications
You must be signed in to change notification settings - Fork 2
/
hpo_deephyper_subprocess_train.sh
47 lines (35 loc) · 1.36 KB
/
hpo_deephyper_subprocess_train.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
#!/bin/bash
# bash subprocess_train.sh ml_data/CCLE-CCLE/split_0 ml_data/CCLE-CCLE/split_0 out_model/CCLE/split_0
# CUDA_VISIBLE_DEVICES=5 bash subprocess_train.sh ml_data/CCLE-CCLE/split_0 ml_data/CCLE-CCLE/split_0 out_model/CCLE/split_0
# Need to comment this when using ' eval "$(conda shell.bash hook)" '
# set -e
# Activate conda env for model using "conda activate myenv"
# https://saturncloud.io/blog/activating-conda-environments-from-scripts-a-guide-for-data-scientists
# https://stackoverflow.com/questions/34534513/calling-conda-source-activate-from-bash-script
# This doesn't work w/o eval "$(conda shell.bash hook)"
CONDA_ENV=$1
echo "Activated conda commands in shell script"
conda_path=$(dirname $(dirname $(which conda)))
source $conda_path/bin/activate $CONDA_ENV
echo "Activated conda env $CONDA_ENV"
# get mandatory arguments
SCRIPT=$2
input_dir=$3
output_dir=$4
epochs=$5
CUDA_VISIBLE_DEVICES=$6
command="python $SCRIPT --input_dir $input_dir --output_dir $output_dir --epochs $epochs "
# append hyperparameter arguments to python call
for i in $(seq 7 $#)
do
if [ $(($i % 2)) == 0 ]; then
command="${command} ${!i}"
else
command="${command} --${!i}"
fi
done
echo "command: $command"
# run python script
CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES} $command
source $conda_path/bin/deactivate
echo "Deactivated conda env $CONDA_ENV"