Skip to content

Commit

Permalink
Merge pull request #121 from kengz/installation
Browse files Browse the repository at this point in the history
Installation update
  • Loading branch information
kengz authored Apr 15, 2017
2 parents aadb4c4 + aa930f5 commit 13c208f
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 106 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ htmlcov/
.coverage
venv/
ENV/
.env/
openai_lab/
src/

node_modules/

Expand Down
6 changes: 4 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@ module.exports = function(grunt) {
eStr = resumeExperimentStr(eStr)
}

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;'

// override with custom command if has 'python'
var pyCmd = _.includes(eStr, 'python') ? eStr : `python3 main.py${bestCmd()}${debugCmd()}${quietCmd()} -t 5 -e ${eStr}`
const cmd = `${remoteCmd()} ${pyCmd} | tee ./data/terminal.log; ${notiCmd(eStr)}`
const pyCmd = _.includes(eStr, 'python') ? eStr : `python3 main.py${bestCmd()}${debugCmd()}${quietCmd()} -t 5 -e ${eStr}`
const cmd = `${remoteCmd()} ${envCmd} ${pyCmd} | tee ./data/terminal.log; ${notiCmd(eStr)}`
grunt.log.ok(`Composed command: ${cmd}`)
return cmd
}
Expand Down
135 changes: 41 additions & 94 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -1,114 +1,61 @@
#!/bin/bash
# This script runs the same sequence as the CircleCI build
# Run this as:
# bin/setup


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


read -p "
================================================
Welcome to the OpenAI Lab setup script;
This will invoke sudo; alternatively,
inspect bin/setup_ubuntu or bin/setup_macOS and run the lines manually.
Press enter to continue, Ctrl+c to quit:
================================================
"

# copy keys file if not already exist
BIN_DIR=`pwd`/bin
$BIN_DIR/copy-config

# install system dependencies
if [ $(uname) == "Darwin" ]; then
if which brew >/dev/null; then
echo "Brew is already installed"
else
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
else
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get update
sudo apt-get install -y gcc-4.9 g++-4.9 libhdf5-dev libopenblas-dev git
# determine if is Mac OSX, or Linux; then run accordingly
if [ $(uname) == "Darwin" ];
# Mac runs below
then (
$BIN_DIR/setup_macOS;
);
else (
$BIN_DIR/setup_ubuntu;
);
fi

# install python
if which python3 >/dev/null; then
echo "Python3 is already installed"
else
if [ $(uname) == "Darwin" ]; then
brew install python3
else
sudo apt-get -y install python3-dev python3-pip python3-setuptools
fi
fi

# install nodejs (for npm and file watcher)
if which node >/dev/null; then
echo "Nodejs is already installed"
else
if [ $(uname) == "Darwin" ]; then
brew install node
else
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
fi
fi
echo "
================================================
# install npm modules
if [ -d ./node_modules ]; then
echo "Npm modules already installed"
else
npm install
sudo npm i -g grunt-cli
fi
Setup done.
Running basic installation checks.
# install noti
if [ $(uname) == "Darwin" ]; then
curl -L https://github.com/variadico/noti/releases/download/v2.5.0/noti2.5.0.darwin-amd64.tar.gz | tar -xz
sudo mv noti /usr/local/bin/
else
curl -L https://github.com/variadico/noti/releases/download/v2.5.0/noti2.5.0.linux-amd64.tar.gz | tar -xz
sudo mv noti /usr/bin/
fi
================================================
"

# install common dependencies from from
sudo python3 -m pip install -U pip
sudo python3 -m pip install six
sudo python3 -m pip install h5py
sudo python3 -m pip install numpy
sudo python3 -m pip install scipy
sudo python3 -m pip install matplotlib
sudo python3 -m pip install seaborn
sudo python3 -m pip install pandas
sudo python3 -m pip install atari_py
sudo python3 -m pip install Pillow
sudo python3 -m pip install PyOpenGL
sudo python3 -m pip install glances
sudo python3 -m pip install mem_top
sudo python3 -m pip install pytest-cov
sudo python3 -m pip install pytest-xdist
sudo python3 -m pip install codacy-coverage

# install tensorflow
if [ $(uname) == "Darwin" ]; then
sudo python3 -m pip install tensorflow
else
sudo python3 -m pip install tensorflow-gpu
fi
# post-installation checks
python3 -c "import tensorflow; print('tensorflow version:'); print(tensorflow.__version__)"

# install theano
if which clang >/dev/null; then
echo "clang is already installed"
else
if [ $(uname) == "Darwin" ]; then
brew install --with-clang llvm
fi
fi
# sudo pip3 install --upgrade --no-deps git+git://github.com/Theano/Theano.git
sudo python3 -m pip install theano==0.8.2
python3 -c "import theano; print('theano version:'); print(theano.__version__)"

# install keras
sudo python3 -m pip install keras

# install full openai gym
if [ $(uname) == "Darwin" ]; then
brew install cmake boost boost-python sdl2 swig wget
else
sudo apt-get install -y cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev python-opengl libboost-all-dev libsdl2-dev swig
fi
git clone https://github.com/openai/gym.git && cd gym && sudo python3 -m pip install -e .[all] && cd ..
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 ..
python3 -c "import gym; gym.make('LunarLander-v2')"
python3 -c "import gym; gym.make('SpaceInvaders-v0')"


echo "
================================================
Installation complete.
================================================
"
50 changes: 50 additions & 0 deletions bin/setup_macOS
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
# This script sets up OpenAI Lab for macOS

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

# install system dependencies
if which brew >/dev/null; then
echo "Brew is already installed"
else
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi

# system dependencies for full openai gym
hb_list=(cmake boost boost-python sdl2 swig wget)
for item in "${hb_list[@]}"; do
brew info "${item}" | grep --quiet 'Not installed' && brew install "${item}"
done

# install noti for auto-notification
if which noti >/dev/null; then
echo "Noti is already installed"
else
curl -L https://github.com/variadico/noti/releases/download/v2.5.0/noti2.5.0.darwin-amd64.tar.gz | tar -xz
sudo mv noti /usr/local/bin/
fi

# install nodejs (for npm and file watcher)
if which node >/dev/null; then
echo "Nodejs is already installed"
else
brew install node
fi
# install npm modules
if [ -d ./node_modules ]; then
echo "Npm modules already installed"
else
npm install; sudo npm i -g grunt-cli
fi

# install python3
if which python3 >/dev/null; then
echo "Python3 is already installed"
else
brew install python3
fi

# install python dependencies
sudo python3 -m pip install -r requirements.txt
45 changes: 45 additions & 0 deletions bin/setup_ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# This script sets up OpenAI Lab for Linux Ubuntu

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

# install system dependencies
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get update
sudo apt-get install -y gcc-4.9 g++-4.9 libhdf5-dev libopenblas-dev git

# system dependencies for full openai gym
sudo apt-get install -y cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev python-opengl libboost-all-dev libsdl2-dev swig

# install noti for auto-notification
if which noti >/dev/null; then
echo "Noti is already installed"
else
curl -L https://github.com/variadico/noti/releases/download/v2.5.0/noti2.5.0.linux-amd64.tar.gz | tar -xz
sudo mv noti /usr/bin/
fi

# install nodejs (for npm and file watcher)
if which node >/dev/null; then
echo "Nodejs is already installed"
else
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
fi
# install npm modules
if [ -d ./node_modules ]; then
echo "Npm modules already installed"
else
npm install; sudo npm i -g grunt-cli
fi

# install python3
if which python3 >/dev/null; then
echo "Python3 is already installed"
else
sudo apt-get -y install python3-dev python3-pip python3-setuptools
fi

# install python dependencies
sudo python3 -m pip install -r requirements.txt
9 changes: 3 additions & 6 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ machine:
dependencies:
pre:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get update
- sudo apt-get install -y gcc-4.9 g++-4.9 libhdf5-dev libopenblas-dev git python3-dev python3-setuptools
- sudo apt-get install -y gcc-4.9 g++-4.9 libhdf5-dev libopenblas-dev git python3-tk tk-dev python3-dev python3-setuptools
- sudo apt-get install -y cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev python-opengl libboost-all-dev libsdl2-dev swig
- pip install -U pip
- pip install six h5py numpy scipy matplotlib seaborn pandas atari_py Pillow PyOpenGL glances mem_top pytest-cov pytest-xdist codacy-coverage
override:
- pip install tensorflow
- pip install theano
- pip install keras
- git clone https://github.com/openai/gym.git && cd gym && pip install -e .[all] && cd ..
- pip install -r requirements.txt
- mkdir ~/.keras && cp ./config/keras.json ~/.keras/
test:
override:
Expand Down
3 changes: 1 addition & 2 deletions config/example-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"NOTI_SLACK_DEST": "#rl-monitor",
"NOTI_SLACK_TOK": "GET_SLACK_BOT_TOKEN_FROM_https://my.slack.com/services/new/bot",
"experiments": [
"dev_dqn",
"dqn"
"quickstart_dqn"
]
}
23 changes: 23 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: openai_lab
channels:
- conda-forge
dependencies:
- python>=3.5
- anaconda
- six
- h5py
- matplotlib==1.4.3
- seaborn>=0.7.1
- Pillow>=3.3.1
- PyOpenGL>=3.1.0
- glances>=2.6.2
- pytest-cov>=2.3.1
- pytest-xdist>=1.15.0
- pip:
- codacy-coverage>=1.3.3
- mem_top==0.1.5
- atari_py>=0.0.18
- cmake==0.6.0
- tensorflow>=1.0.0
- Keras>=1.2.2,<2.0.0
- "--editable=git+https://github.com/kengz/gym.git#egg=gym[all]"
18 changes: 18 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
six
h5py
numpy>=1.12
scipy>=0.18
matplotlib==1.4.3
seaborn>=0.7.1
pandas>=0.18.1
atari_py>=0.0.18
Pillow>=3.3.1
PyOpenGL>=3.1.0
glances>=2.6.2
mem_top==0.1.5
pytest-cov>=2.3.1
pytest-xdist>=1.15.0
codacy-coverage>=1.3.3
tensorflow>=1.0.0
Keras>=1.2.2,<2.0.0
-e git+https://github.com/kengz/gym.git#egg=gym[all]
23 changes: 23 additions & 0 deletions rl/spec/classic_experiment_specs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
{
"quickstart_dqn": {
"problem": "CartPole-v0",
"Agent": "DQN",
"HyperOptimizer": "GridSearch",
"Memory": "LinearMemoryWithForgetting",
"Optimizer": "AdamOptimizer",
"Policy": "BoltzmannPolicy",
"PreProcessor": "NoPreProcessor",
"param": {
"lr": 0.02,
"gamma": 0.99,
"hidden_layers": [64],
"hidden_layers_activation": "sigmoid",
"exploration_anneal_episodes": 10
},
"param_range": {
"lr": [0.001, 0.01],
"hidden_layers": [
[32],
[64]
]
}
},
"dqn_epsilon": {
"problem": "CartPole-v0",
"Agent": "DQN",
Expand Down
2 changes: 0 additions & 2 deletions test/test_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ def test_mountain_dqn(cls):
data_df = run('mountain_dqn')
assert isinstance(data_df, pd.DataFrame)

@unittest.skipIf(environ.get('CI'),
"OpenAI Gym Box2D swigconstant error, issue #100")
@classmethod
def test_lunar_dqn(cls):
data_df = run('lunar_dqn')
Expand Down

0 comments on commit 13c208f

Please sign in to comment.