-
Notifications
You must be signed in to change notification settings - Fork 1
/
polee
executable file
·55 lines (48 loc) · 1.5 KB
/
polee
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
#!/usr/bin/env bash
# Polee is a julia program, but options that rely on environment variables. We
# use this shell script wrapper to extract those options and set the right
# variables before running the real program.
# This trick taken from: https://stackoverflow.com/a/23378780
ncpus=$([[ $(uname) = 'Darwin' ]] &&
sysctl -n hw.physicalcpu_max ||
lscpu -p | egrep -v '^#' | sort -u -t, -k 2,4 | wc -l)
export JULIA_NUM_THREADS=$ncpus
unused_args=()
while [[ $# -gt 0 ]]; do
case $1 in
--no-gpu)
echo NO GPU
export CUDA_VISIBLE_DEVICES=''
shift
;;
-t|--num-threads)
export JULIA_NUM_THREADS="$2"
export OMP_NUM_THREADS="$2"
shift
shift
;;
*)
unused_args+=("$1")
shift
;;
esac
done
# Intercept and run models
if [[ ${unused_args[0]} == "model" ]]; then
# Find polee source directory
polee_dir=`julia -e 'import Polee; print(joinpath(dirname(pathof(Polee)), ".."))'`
if [[ ${#unused_args[@]} -gt 1 ]]; then
model_file=${polee_dir}/models/${unused_args[1]}.jl
if [[ ! -e $model_file ]]; then
echo "Model ${unused_args[1]} does not exist." >&2
exit 1
fi
julia $model_file -- "${unused_args[@]:2}"
else
echo "Model name must be provided to \"polee model\"" >&2
exit 1
fi
else
# Otherwise run the regular program
julia -e "import Polee; Polee.main()" -- "${unused_args[@]}"
fi