Skip to content

Commit

Permalink
v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lorifranke committed Nov 16, 2023
0 parents commit 9ac0eab
Show file tree
Hide file tree
Showing 219 changed files with 243,693 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
**/.DS_Store
.idea
ui/.svelte-kit
ui/node_modules
ui/package-lock.json
server/build
server/AutoRL_X_Server.egg-info
server/logs/*
server/tuner_*
**/__pycache__
**/build
server/gyms
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Welcome to AutoRL X 👋

Interactive Platform for Automated Reinforcement Learning on the Web

![](autorlx.png)

With Auto RL X you can interactively create reinforcement learning gyms, execute optimization runs and visually inspect agent performance directly in your browser. 🖥 📊 🤖

AutoRL X is provided under GPL 3.0 license.

The code base further depends on:

- https://github.com/lorifranke/arlo.git (a fork of https://github.com/arlo-lib/ARLO)
- https://github.com/lorifranke/mushroom-rl.git (a fork of https://github.com/MushroomRL/mushroom-rl)

## Installation
This will deploy a MySQL database, AutoRL X Server and the AutoRL X web interface in your local Docker environment using Docker Compose.

### Prerequisites 🐳

Install [Docker](https://www.docker.com/) from https://www.docker.com/.

### 🟢 Deploy
From your terminal, to pull and deploy prebuilt images, execute
```shell
sh deploy_by_pull.sh # Deploys prebuilt images and starts the composition
```
Alternatively, to build and deploy images locally, execute
```shell
sh deploy_by_build.sh # Builds locally, deploys and starts the composition
```
Don't hesitate to [open an issue](https://github.com/lorifranke/autorlx/issues/new) if you need help.

### 🟡 Restart
After deployment, to stop and restart the composition, execute
```shell
sh stop.sh # Stops the composition
sh start.sh # Starts the compositions
```

### 🔴 Undeploy
From your terminal, execute
```shell
sh undeploy.sh # Stops and undeploys the composition
```


## Developers

#### Run AutoRL X Server w/ Python:

```shell
cd server
pip install . # Installs dependencies
python main.py & # Listens to port 8000
```

#### Run AutoRL X w/ NPM:

```shell
cd ..
npm install # Installs dependencies
npm run dev & # Listens to port 5173
```

Binary file added autorlx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions base/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
generated_cymj*
_pyxbld*
dist
cache
.idea/*
*~
.*~
*#*#
*.o
*.dat
*.prof
*.lprof
*.local
.realsync
.DS_Store
**/*.egg-info
.cache
*.ckpt
*.log
.ipynb_checkpoints
venv/
.vimrc
*.settings
*.svn
.project
.pydevproject
tags
*sublime-project
*sublime-workspace
# Intermediate outputs
__pycache__
**/__pycache__
*.pb.*
*.pyc
*.swp
*.swo
# generated data
*.rdb
*.db
*.avi
# mujoco outputs
MUJOCO_LOG.TXT
model.txt
.window_data
.idea/*.xml
outputfile
tmp*
cymj.c
**/.git
**/*.so
8 changes: 8 additions & 0 deletions base/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: generic

before_install:
- curl $MUJOCO_FOR_LINUX | tar -xz ./mjkey.txt
- docker build -t image-under-test .

script:
- docker run --rm image-under-test
88 changes: 88 additions & 0 deletions base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
FROM nvidia/cuda:12.1.0-devel-ubuntu18.04

RUN apt-get update -q && DEBIAN_FRONTEND=noninteractive apt-get install -y \
curl \
git \
libgl1-mesa-dev \
libgl1-mesa-glx \
libglew-dev \
libosmesa6-dev \
software-properties-common \
net-tools \
vim \
wget \
xpra \
supervisor \
swig \
xserver-xorg-dev \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

RUN DEBIAN_FRONTEND=noninteractive add-apt-repository --yes ppa:deadsnakes/ppa && apt-get update -q
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \
python3.8 \
python3.8-dev \
python3.8-distutils \
python3-pip

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
RUN update-alternatives --set python /usr/bin/python3.8
RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
RUN update-alternatives --set pip /usr/bin/pip3

RUN python -m pip install --upgrade pip
RUN python -m pip install --upgrade Pillow

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev \
libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk \
libharfbuzz-dev libfribidi-dev libxcb1-dev

# RUN python -m ensurepip --upgrade

# RUN update-alternatives --set python /usr/bin/python3.6
# RUN update-alternatives --set pip /usr/bin/pip3.6

#RUN rm /usr/bin/python
#RUN ln -s /env/bin/python3.6 /usr/bin/python
#RUN ln -s /env/bin/pip3.6 /usr/bin/pip
#RUN ln -s /env/bin/pytest /usr/bin/pytest

RUN curl -o /usr/local/bin/patchelf https://s3-us-west-2.amazonaws.com/openai-sci-artifacts/manual-builds/patchelf_0.9_amd64.elf \
&& chmod +x /usr/local/bin/patchelf

ENV LANG C.UTF-8

RUN mkdir -p /root/.mujoco \
&& wget https://mujoco.org/download/mujoco210-linux-x86_64.tar.gz -O mujoco.tar.gz \
&& tar -xf mujoco.tar.gz -C /root/.mujoco \
&& rm mujoco.tar.gz

ENV LD_LIBRARY_PATH /root/.mujoco/mujoco210/bin:${LD_LIBRARY_PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib64:${LD_LIBRARY_PATH}

COPY vendor/Xdummy /usr/local/bin/Xdummy
RUN chmod +x /usr/local/bin/Xdummy

# Workaround for https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-375/+bug/1674677
COPY ./vendor/10_nvidia.json /usr/share/glvnd/egl_vendor.d/10_nvidia.json

WORKDIR /mujoco_py
COPY ./requirements.txt /mujoco_py/
COPY ./requirements.dev.txt /mujoco_py/
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir -r requirements.dev.txt

RUN pip install numpy scikit-learn==1.0.2 nvidia-cusolver-cu12==11.4.5.107 nvidia-curand-cu12==10.3.2.106
RUN pip install nvidia-cusparse-cu12==12.1.0.106 nvidia-cublas-cu12==12.1.3.1 nvidia-cudnn-cu12==8.9.2.26 triton==2.1.0
RUN pip install nvidia-nccl-cu12==2.18.1 nvidia-cufft-cu12==11.0.2.54 nvidia-nvjitlink-cu12 mpmath>=0.19 torch==2.1.0
RUN pip install gym==0.22.0 opencv-python==4.8.1.78 scipy==1.7.3 xgboost==1.7.1 cython==0.29.21 matplotlib==3.5.0
RUN pip install plotly==5.4.0 optuna==2.10.0 catboost==1.2 fastapi==0.92.0 websockets==10.4 fastparquet==2023.2.0
RUN pip install uvicorn==0.19.0 pydantic==1.10.12 requests==2.28.1 email-validator==2.0.0.post2 pymysql==1.1.0
RUN pip install cryptography==41.0.4 ale-py==0.7.5 Pillow opencv-python box2d-py==2.3.5 pybullet dm_control==1.0.9
RUN pip install pyqtgraph joblib==1.1.0 tqdm==4.66.1 pygame==2.5.2 setuptools==58.2.0 mujoco-py==2.1.2.14
RUN apt install -y patchelf
RUN python -c 'import mujoco_py'
COPY . /mujoco_py

# ENTRYPOINT ["/mujoco_py/vendor/Xdummy-entrypoint"]
# CMD ["pytest"]
# RUN #python setup.py install
36 changes: 36 additions & 0 deletions base/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# mujoco-py

The MIT License

Copyright (c) 2017 OpenAI (http://openai.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

# Mujoco models
This work is derived from [MuJuCo models](http://www.mujoco.org/forum/index.php?resources/) used under the following license:
```
This file is part of MuJoCo.
Copyright 2009-2015 Roboti LLC.
Mujoco :: Advanced physics simulation engine
Source : www.roboti.us
Version : 1.31
Released : 23Apr16
Author :: Vikash Kumar
Contacts : [email protected]
```
9 changes: 9 additions & 0 deletions base/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include pyproject.toml
include requirements.txt
include requirements.dev.txt
recursive-include mujoco_py *.h *.py *.pyx *.pxd *.pxi *.xml *.c
include mujoco_py/gl/*.c
include setup.py
include mujoco_py/generated/cymj_*_linuxcpuextensionbuilder.so
include mujoco_py/generated/cymj_*_linuxgpuextensionbuilder.so
include xmls/*
82 changes: 82 additions & 0 deletions base/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
SHELL := /bin/bash
.PHONY: all clean build test mount_shell shell upload check-env

VERSION := `cd mujoco_py; python -c "from version import get_version;print(get_version())"; cd ..`
PYTHON_VERSION := "36"
DOCKER_NAME := quay.io/openai/mujoco_py:$(USER)_$(VERSION)
DOCKER := $(shell type -p nvidia-docker || echo docker)
UUID := $(shell uuidgen)

all: test

clean:
rm -rf mujoco_py.egg-info
rm -rf */__pycache__
rm -rf */*/__pycache__
rm -rf mujoco_py/generated/_pyxbld*
rm -rf mujoco_py/generated/*.so
rm -rf mujoco_py/generated/*.dll
rm -rf mujoco_py/generated_cymj*
rm -rf mujoco_py/cythonlock_*.pyc
rm -rf mujoco_py/cymj.c
rm -rf mujoco_py/__pycache__
rm -rf dist
rm -rf build

build:
docker build -t $(DOCKER_NAME) .

push:
docker push $(DOCKER_NAME)

pull:
docker pull $(DOCKER_NAME)

test: build
# run it interactive mode so we can abort with CTRL+C
$(DOCKER) run --rm -i $(DOCKER_NAME) pytest

test_gpu: build push
$(eval NODE="$(shell cirrascale-cli reserve -g 1080ti -t 10m)")
$(eval GPUS="$(shell echo $(NODE)| grep -oE '[^:]+f' | cut -c1-1 )")
$(eval NODE="$(shell echo $(NODE)| grep -oE '[^=]+:' | sed 's/://')")
ssh -t -o StrictHostKeyChecking=no $(NODE) 'docker pull $(DOCKER_NAME) && export GPUS=$(GPUS) && nvidia-docker run --rm -e GPUS -i $(DOCKER_NAME) pytest -m "not requires_glfw"'

shell:
$(DOCKER) run --rm -it $(DOCKER_NAME) /bin/bash

mount:
$(DOCKER) run -e GPUS -it -v `pwd`:/mujoco_py-dev $(DOCKER_NAME) /bin/bash -c "pip uninstall -y mujoco-py; rm -rf /mujoco_py; (cd /mujoco_py-dev; export PYTHONPATH='/mujoco_py-dev'; /bin/bash)"

cirra:
$(eval NODE="$(shell cirrascale-cli reserve)")
$(eval GPUS="$(shell echo $(NODE)| grep -oE '[^:]+f' | cut -c1-1 )")
$(eval NODE="$(shell echo $(NODE)| grep -oE '[^=]+:' | sed 's/://')")
tmux new-session "while :; do rsync -e 'ssh -o StrictHostKeyChecking=no' --delete -rzai --out-format='%t %f %b' --chmod=Du+rwx --exclude='*extensionbuilder.so' --exclude='dist' --exclude='cymj.c' --exclude='_pyxbld_*' --exclude='__pycache__' --exclude='*.egg-info' --exclude='.cache' --exclude='.git' --exclude='*.pyc' --exclude='*.swp' --exclude='.idea' . $(NODE):~/mujoco_py/ ; sleep 1; done" \; \
split-window "ssh -t -o StrictHostKeyChecking=no $(NODE) 'mkdir -p ~/mujoco_py && cd ~/mujoco_py && export GPUS=$(GPUS) && /bin/bash'; " \; select-layout 9ce0,204x51,0,0[204x4,0,0,32,204x46,0,5,33]

# Requires to generate all *.so files. Call make generate_mac_so on mac;
# Call make generate_cpu_so on mac or linux.
#
# Call make generate_gpu_so on linux with nvidia-docker. The easiest way is to get to cirrascale, and call: make cirra.
# Then you have to copy back generated cymj_linuxgpuextensionbuilder.so file.
#
# Gather all *.so files.
upload:
# Commented out for now, binary distributions seem not to work very well
# test -f ./mujoco_py/generated/cymj_$(VERSION)_$(PYTHON_VERSION)_linuxcpuextensionbuilder.so || exit -1
# test -f ./mujoco_py/generated/cymj_$(VERSION)_$(PYTHON_VERSION)_linuxgpuextensionbuilder.so || exit -1
rm -rf dist
python setup.py sdist
twine upload dist/*

generate_gpu_so:
rm -f ./mujoco_py/generated/cymj_*_linuxgpuextensionbuilder.so
nvidia-docker run -it --name $(UUID) $(DOCKER_NAME) bash -c "make clean;python -c 'import mujoco_py'"
nvidia-docker cp $(UUID):/mujoco_py/mujoco_py/generated/cymj_$(VERSION)_$(PYTHON_VERSION)_linuxgpuextensionbuilder.so mujoco_py/generated/

generate_cpu_so:
rm -f ./mujoco_py/generated/cymj_*_linuxcpuextensionbuilder.so
docker run -it --name $(UUID) $(DOCKER_NAME) bash -c "make clean;python -c 'import mujoco_py'"
docker cp $(UUID):/mujoco_py/mujoco_py/generated/cymj_$(VERSION)_$(PYTHON_VERSION)_linuxcpuextensionbuilder.so mujoco_py/generated/

Loading

0 comments on commit 9ac0eab

Please sign in to comment.