Skip to content

Commit 13c208f

Browse files
authored
Merge pull request #121 from kengz/installation
Installation update
2 parents aadb4c4 + aa930f5 commit 13c208f

File tree

11 files changed

+211
-106
lines changed

11 files changed

+211
-106
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ htmlcov/
3434
.coverage
3535
venv/
3636
ENV/
37+
.env/
38+
openai_lab/
39+
src/
3740

3841
node_modules/
3942

Gruntfile.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,11 @@ module.exports = function(grunt) {
110110
eStr = resumeExperimentStr(eStr)
111111
}
112112

113+
const envCmd = 'if (conda env list | grep --quiet "openai_lab"); then echo "activating conda"; source activate openai_lab; elif [ -d ./.env ]; then echo "activating virtualenv"; source .env/bin/activate; else echo "using system python"; fi;'
114+
113115
// override with custom command if has 'python'
114-
var pyCmd = _.includes(eStr, 'python') ? eStr : `python3 main.py${bestCmd()}${debugCmd()}${quietCmd()} -t 5 -e ${eStr}`
115-
const cmd = `${remoteCmd()} ${pyCmd} | tee ./data/terminal.log; ${notiCmd(eStr)}`
116+
const pyCmd = _.includes(eStr, 'python') ? eStr : `python3 main.py${bestCmd()}${debugCmd()}${quietCmd()} -t 5 -e ${eStr}`
117+
const cmd = `${remoteCmd()} ${envCmd} ${pyCmd} | tee ./data/terminal.log; ${notiCmd(eStr)}`
116118
grunt.log.ok(`Composed command: ${cmd}`)
117119
return cmd
118120
}

bin/setup

Lines changed: 41 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,61 @@
11
#!/bin/bash
22
# This script runs the same sequence as the CircleCI build
3+
# Run this as:
4+
# bin/setup
5+
36

47
# Fail on the first error; killable by SIGINT
58
set -e
69
trap "exit" INT
710

11+
12+
read -p "
13+
================================================
14+
15+
Welcome to the OpenAI Lab setup script;
16+
This will invoke sudo; alternatively,
17+
inspect bin/setup_ubuntu or bin/setup_macOS and run the lines manually.
18+
19+
Press enter to continue, Ctrl+c to quit:
20+
21+
================================================
22+
"
23+
824
# copy keys file if not already exist
925
BIN_DIR=`pwd`/bin
1026
$BIN_DIR/copy-config
1127

12-
# install system dependencies
13-
if [ $(uname) == "Darwin" ]; then
14-
if which brew >/dev/null; then
15-
echo "Brew is already installed"
16-
else
17-
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
18-
fi
19-
else
20-
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get update
21-
sudo apt-get install -y gcc-4.9 g++-4.9 libhdf5-dev libopenblas-dev git
28+
# determine if is Mac OSX, or Linux; then run accordingly
29+
if [ $(uname) == "Darwin" ];
30+
# Mac runs below
31+
then (
32+
$BIN_DIR/setup_macOS;
33+
);
34+
else (
35+
$BIN_DIR/setup_ubuntu;
36+
);
2237
fi
2338

24-
# install python
25-
if which python3 >/dev/null; then
26-
echo "Python3 is already installed"
27-
else
28-
if [ $(uname) == "Darwin" ]; then
29-
brew install python3
30-
else
31-
sudo apt-get -y install python3-dev python3-pip python3-setuptools
32-
fi
33-
fi
3439

35-
# install nodejs (for npm and file watcher)
36-
if which node >/dev/null; then
37-
echo "Nodejs is already installed"
38-
else
39-
if [ $(uname) == "Darwin" ]; then
40-
brew install node
41-
else
42-
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
43-
sudo apt-get install -y nodejs
44-
fi
45-
fi
40+
echo "
41+
================================================
4642
47-
# install npm modules
48-
if [ -d ./node_modules ]; then
49-
echo "Npm modules already installed"
50-
else
51-
npm install
52-
sudo npm i -g grunt-cli
53-
fi
43+
Setup done.
44+
Running basic installation checks.
5445
55-
# install noti
56-
if [ $(uname) == "Darwin" ]; then
57-
curl -L https://github.com/variadico/noti/releases/download/v2.5.0/noti2.5.0.darwin-amd64.tar.gz | tar -xz
58-
sudo mv noti /usr/local/bin/
59-
else
60-
curl -L https://github.com/variadico/noti/releases/download/v2.5.0/noti2.5.0.linux-amd64.tar.gz | tar -xz
61-
sudo mv noti /usr/bin/
62-
fi
46+
================================================
47+
"
6348

64-
# install common dependencies from from
65-
sudo python3 -m pip install -U pip
66-
sudo python3 -m pip install six
67-
sudo python3 -m pip install h5py
68-
sudo python3 -m pip install numpy
69-
sudo python3 -m pip install scipy
70-
sudo python3 -m pip install matplotlib
71-
sudo python3 -m pip install seaborn
72-
sudo python3 -m pip install pandas
73-
sudo python3 -m pip install atari_py
74-
sudo python3 -m pip install Pillow
75-
sudo python3 -m pip install PyOpenGL
76-
sudo python3 -m pip install glances
77-
sudo python3 -m pip install mem_top
78-
sudo python3 -m pip install pytest-cov
79-
sudo python3 -m pip install pytest-xdist
80-
sudo python3 -m pip install codacy-coverage
81-
82-
# install tensorflow
83-
if [ $(uname) == "Darwin" ]; then
84-
sudo python3 -m pip install tensorflow
85-
else
86-
sudo python3 -m pip install tensorflow-gpu
87-
fi
49+
# post-installation checks
8850
python3 -c "import tensorflow; print('tensorflow version:'); print(tensorflow.__version__)"
89-
90-
# install theano
91-
if which clang >/dev/null; then
92-
echo "clang is already installed"
93-
else
94-
if [ $(uname) == "Darwin" ]; then
95-
brew install --with-clang llvm
96-
fi
97-
fi
98-
# sudo pip3 install --upgrade --no-deps git+git://github.com/Theano/Theano.git
99-
sudo python3 -m pip install theano==0.8.2
100-
python3 -c "import theano; print('theano version:'); print(theano.__version__)"
101-
102-
# install keras
103-
sudo python3 -m pip install keras
104-
105-
# install full openai gym
106-
if [ $(uname) == "Darwin" ]; then
107-
brew install cmake boost boost-python sdl2 swig wget
108-
else
109-
sudo apt-get install -y cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev python-opengl libboost-all-dev libsdl2-dev swig
110-
fi
111-
git clone https://github.com/openai/gym.git && cd gym && sudo python3 -m pip install -e .[all] && cd ..
112-
git clone https://github.com/pybox2d/pybox2d && cd pybox2d/ && sudo python3 setup.py clean && sudo python3 setup.py build && sudo python3 setup.py install && cd ..
11351
python3 -c "import gym; gym.make('LunarLander-v2')"
11452
python3 -c "import gym; gym.make('SpaceInvaders-v0')"
53+
54+
55+
echo "
56+
================================================
57+
58+
Installation complete.
59+
60+
================================================
61+
"

bin/setup_macOS

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# This script sets up OpenAI Lab for macOS
3+
4+
# Fail on the first error; killable by SIGINT
5+
set -e
6+
trap "exit" INT
7+
8+
# install system dependencies
9+
if which brew >/dev/null; then
10+
echo "Brew is already installed"
11+
else
12+
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
13+
fi
14+
15+
# system dependencies for full openai gym
16+
hb_list=(cmake boost boost-python sdl2 swig wget)
17+
for item in "${hb_list[@]}"; do
18+
brew info "${item}" | grep --quiet 'Not installed' && brew install "${item}"
19+
done
20+
21+
# install noti for auto-notification
22+
if which noti >/dev/null; then
23+
echo "Noti is already installed"
24+
else
25+
curl -L https://github.com/variadico/noti/releases/download/v2.5.0/noti2.5.0.darwin-amd64.tar.gz | tar -xz
26+
sudo mv noti /usr/local/bin/
27+
fi
28+
29+
# install nodejs (for npm and file watcher)
30+
if which node >/dev/null; then
31+
echo "Nodejs is already installed"
32+
else
33+
brew install node
34+
fi
35+
# install npm modules
36+
if [ -d ./node_modules ]; then
37+
echo "Npm modules already installed"
38+
else
39+
npm install; sudo npm i -g grunt-cli
40+
fi
41+
42+
# install python3
43+
if which python3 >/dev/null; then
44+
echo "Python3 is already installed"
45+
else
46+
brew install python3
47+
fi
48+
49+
# install python dependencies
50+
sudo python3 -m pip install -r requirements.txt

bin/setup_ubuntu

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
# This script sets up OpenAI Lab for Linux Ubuntu
3+
4+
# Fail on the first error; killable by SIGINT
5+
set -e
6+
trap "exit" INT
7+
8+
# install system dependencies
9+
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get update
10+
sudo apt-get install -y gcc-4.9 g++-4.9 libhdf5-dev libopenblas-dev git
11+
12+
# system dependencies for full openai gym
13+
sudo apt-get install -y cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev python-opengl libboost-all-dev libsdl2-dev swig
14+
15+
# install noti for auto-notification
16+
if which noti >/dev/null; then
17+
echo "Noti is already installed"
18+
else
19+
curl -L https://github.com/variadico/noti/releases/download/v2.5.0/noti2.5.0.linux-amd64.tar.gz | tar -xz
20+
sudo mv noti /usr/bin/
21+
fi
22+
23+
# install nodejs (for npm and file watcher)
24+
if which node >/dev/null; then
25+
echo "Nodejs is already installed"
26+
else
27+
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
28+
sudo apt-get install -y nodejs
29+
fi
30+
# install npm modules
31+
if [ -d ./node_modules ]; then
32+
echo "Npm modules already installed"
33+
else
34+
npm install; sudo npm i -g grunt-cli
35+
fi
36+
37+
# install python3
38+
if which python3 >/dev/null; then
39+
echo "Python3 is already installed"
40+
else
41+
sudo apt-get -y install python3-dev python3-pip python3-setuptools
42+
fi
43+
44+
# install python dependencies
45+
sudo python3 -m pip install -r requirements.txt

circle.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ machine:
55
dependencies:
66
pre:
77
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get update
8-
- sudo apt-get install -y gcc-4.9 g++-4.9 libhdf5-dev libopenblas-dev git python3-dev python3-setuptools
8+
- sudo apt-get install -y gcc-4.9 g++-4.9 libhdf5-dev libopenblas-dev git python3-tk tk-dev python3-dev python3-setuptools
9+
- sudo apt-get install -y cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev python-opengl libboost-all-dev libsdl2-dev swig
910
- pip install -U pip
10-
- pip install six h5py numpy scipy matplotlib seaborn pandas atari_py Pillow PyOpenGL glances mem_top pytest-cov pytest-xdist codacy-coverage
1111
override:
12-
- pip install tensorflow
13-
- pip install theano
14-
- pip install keras
15-
- git clone https://github.com/openai/gym.git && cd gym && pip install -e .[all] && cd ..
12+
- pip install -r requirements.txt
1613
- mkdir ~/.keras && cp ./config/keras.json ~/.keras/
1714
test:
1815
override:

config/example-default.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"NOTI_SLACK_DEST": "#rl-monitor",
44
"NOTI_SLACK_TOK": "GET_SLACK_BOT_TOKEN_FROM_https://my.slack.com/services/new/bot",
55
"experiments": [
6-
"dev_dqn",
7-
"dqn"
6+
"quickstart_dqn"
87
]
98
}

environment.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: openai_lab
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- python>=3.5
6+
- anaconda
7+
- six
8+
- h5py
9+
- matplotlib==1.4.3
10+
- seaborn>=0.7.1
11+
- Pillow>=3.3.1
12+
- PyOpenGL>=3.1.0
13+
- glances>=2.6.2
14+
- pytest-cov>=2.3.1
15+
- pytest-xdist>=1.15.0
16+
- pip:
17+
- codacy-coverage>=1.3.3
18+
- mem_top==0.1.5
19+
- atari_py>=0.0.18
20+
- cmake==0.6.0
21+
- tensorflow>=1.0.0
22+
- Keras>=1.2.2,<2.0.0
23+
- "--editable=git+https://github.com/kengz/gym.git#egg=gym[all]"

requirements.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
six
2+
h5py
3+
numpy>=1.12
4+
scipy>=0.18
5+
matplotlib==1.4.3
6+
seaborn>=0.7.1
7+
pandas>=0.18.1
8+
atari_py>=0.0.18
9+
Pillow>=3.3.1
10+
PyOpenGL>=3.1.0
11+
glances>=2.6.2
12+
mem_top==0.1.5
13+
pytest-cov>=2.3.1
14+
pytest-xdist>=1.15.0
15+
codacy-coverage>=1.3.3
16+
tensorflow>=1.0.0
17+
Keras>=1.2.2,<2.0.0
18+
-e git+https://github.com/kengz/gym.git#egg=gym[all]

rl/spec/classic_experiment_specs.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
{
2+
"quickstart_dqn": {
3+
"problem": "CartPole-v0",
4+
"Agent": "DQN",
5+
"HyperOptimizer": "GridSearch",
6+
"Memory": "LinearMemoryWithForgetting",
7+
"Optimizer": "AdamOptimizer",
8+
"Policy": "BoltzmannPolicy",
9+
"PreProcessor": "NoPreProcessor",
10+
"param": {
11+
"lr": 0.02,
12+
"gamma": 0.99,
13+
"hidden_layers": [64],
14+
"hidden_layers_activation": "sigmoid",
15+
"exploration_anneal_episodes": 10
16+
},
17+
"param_range": {
18+
"lr": [0.001, 0.01],
19+
"hidden_layers": [
20+
[32],
21+
[64]
22+
]
23+
}
24+
},
225
"dqn_epsilon": {
326
"problem": "CartPole-v0",
427
"Agent": "DQN",

0 commit comments

Comments
 (0)