-
Notifications
You must be signed in to change notification settings - Fork 78
/
run.sh
executable file
·76 lines (61 loc) · 2.42 KB
/
run.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# Copyright 2019 DeepMind Technologies Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
# This script does the following:
# 1. Clones the DQN Zoo repository.
# 2. Builds a Docker image with all necessary dependencies and runs unit tests.
# 3. Starts a short run of DQN on Pong in a GPU-accelerated container.
# Before running:
# * Install Docker version 19.03 or later for the --gpus options.
# * Install NVIDIA Container Toolkit.
# * Enable sudoless docker.
# * Verify installation, e.g. with:
# `docker run --gpus all --rm nvidia/cuda:11.1.1-base nvidia-smi`.
# To remove all containers run:
# `docker rm -vf $(docker ps -a -q)`
# To remove all images run:
# `docker rmi -f $(docker images -a -q)`
set -u -e # Check for uninitialized variables and exit if any command fails.
WORK_DIR_ROOT=${TMPDIR:-/var/tmp/}
WORK_DIR=$(mktemp -d "${WORK_DIR_ROOT}dqnzoo_$(date +"%Y%m%d_%H%M%S")_XXXXXX")
echo "Working directory: $WORK_DIR"
function clean_up() {
echo "Removing $WORK_DIR"
rm -rf "$WORK_DIR"
echo "Removed $WORK_DIR"
}
# Clean up on exit.
trap clean_up INT EXIT TERM
echo "Clone DQN Zoo repository"
git clone https://github.com/deepmind/dqn_zoo.git "$WORK_DIR"
find "$WORK_DIR"
echo "Remove container if it exists"
docker rm dqn_zoo_dqn || true
echo "Remove image if it exists"
docker rmi dqn_zoo:latest || true
echo "Build image with tag 'dqn_zoo:latest' and run tests"
docker build -t dqn_zoo:latest "$WORK_DIR"
echo "Run DQN on GPU in a container named dqn_zoo_dqn"
docker run --gpus all --name dqn_zoo_dqn dqn_zoo:latest \
-m dqn_zoo.dqn.run_atari \
--jax_platform_name=gpu \
--environment_name=pong \
--replay_capacity=1000 \
--target_network_update_period=40 \
--num_iterations=10 \
--num_train_frames=1000 \
--num_eval_frames=500
# Note $WORK_DIR will be removed on exit.
echo "Finished"