-
Notifications
You must be signed in to change notification settings - Fork 24
/
train.sh
executable file
·61 lines (48 loc) · 2.05 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
ENV_NAME="Pong-v0"
LOG_DIR="./models/$ENV_NAME"
TMUX_SESSION_NAME="a3c"
NUM_THREADS=$(nproc --all)
TENSORBOARD_PORT=15000
# Create the log directory.
mkdir -p $LOG_DIR
# Kill previous tmux session. Ignore potential "can't find session" messages.
tmux kill-session -t $TMUX_SESSION_NAME 2> /dev/null
# Initialize a new tmux session.
tmux new-session -s $TMUX_SESSION_NAME -n master -d
# Create a window for each learning thread.
for thread_id in $(seq 0 $(($NUM_THREADS - 1))); do
tmux new-window -t $TMUX_SESSION_NAME -n thread-$thread_id
done
# Create a window for TensorBoard.
tmux new-window -t $TMUX_SESSION_NAME -n tensorboard
# Create a window for observing hardware usage.
tmux new-window -t $TMUX_SESSION_NAME -n htop
# Wait for tmux to finish setting up.
sleep 1
# Start the master thread, which synchronizes worker threads.
tmux send-keys -t $TMUX_SESSION_NAME:master "/usr/bin/python3 thread.py" \
" --env_name=$ENV_NAME" \
" --log_dir=$LOG_DIR" \
" --num_threads=$NUM_THREADS" \
" $@" Enter
# Start worker threads.
for thread_id in $(seq 0 $(($NUM_THREADS - 1))); do
tmux send-keys -t $TMUX_SESSION_NAME:thread-$thread_id \
"/usr/bin/python3 thread.py" \
" --env_name=$ENV_NAME" \
" --log_dir=$LOG_DIR" \
" --num_threads=$NUM_THREADS" \
" --worker_index=$thread_id" \
" $@" Enter
done
# Start TensorBoard.
tmux send-keys -t $TMUX_SESSION_NAME:tensorboard "tensorboard" \
" --port $TENSORBOARD_PORT" \
" --logdir $LOG_DIR" Enter
# Start htop.
tmux send-keys -t $TMUX_SESSION_NAME:htop htop Enter
echo "Started the learning session."
echo "Started TensorBoard at localhost:$TENSORBOARD_PORT."
echo "Use 'tmux attach -t $TMUX_SESSION_NAME' to connect to the session."
echo "Use 'tmux kill-session -t $TMUX_SESSION_NAME' to end the session."