Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Docker Container #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ARG base_img_with_tag=pytorch/pytorch:1.11.0-cuda11.3-cudnn8-devel
FROM ${base_img_with_tag} as base
RUN rm /etc/apt/sources.list.d/cuda.list
RUN rm /etc/apt/sources.list.d/nvidia-ml.list
RUN apt-get -y update && apt-get -y install \
libxrender1 \
libsm6 \
libxext6 \
libxrender-dev && \
apt-get -y clean

RUN conda create -n my-rdkit-env python=3.7
RUN conda init
RUN mkdir -p /usr/src/app/rl_graph_generation
WORKDIR /usr/src/app/rl_graph_generation
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.PHONY: build run_dev_gpu run_dev_no_gpu

base_img_with_tag := pytorch/pytorch:1.11.0-cuda11.3-cudnn8-devel
built_img := gcpn
built_tag := dev
local_dir := $(shell pwd)

gpu_args := -e USER_ID=$(shell id -u) \
-e USER_GP=$(shell id -g) \
-e USERNAME=$(shell id -un) \
--env NVIDIA_VISIBLE_DEVICES=all \
--env NVIDIA_VISIBLE_CAPABILITIES=all \
--env="QT_X11_NO_MITSHM=1" \
--env="XAUTHORITY=$(XAUTH)" \
--volume $(XAUTH):$(XAUTH) \
--volume /tmp/.X11-unix:/tmp/.X11-unix \

no_gpu_args := -e USER_ID=$(shell id -u) \
-e USER_GP=$(shell id -g) \
-e USERNAME=$(shell id -un) \
--env="QT_X11_NO_MITSHM=1" \
--env="XAUTHORITY=$(XAUTH)" \
--volume $(XAUTH):$(XAUTH) \
--volume /tmp/.X11-unix:/tmp/.X11-unix \

gpu_container := --gpus all -it --init $(gpu_args)
no_gpu_container := -it --init $(no_gpu_args)

build:
@docker build --build-arg base_img_with_tag=$(base_img_with_tag) . -f Dockerfile --network=host --tag ${built_img}:${built_tag}


run_dev_gpu:
@docker run -d --net=host $(gpu_container) -v $(local_dir):/usr/src/app/rl_graph_generation $(built_img):$(built_tag)

run_dev_no:
@docker run -d --net=host $(no_gpu_container) -v $(local_dir):/usr/src/app/rl_graph_generation ${built_img}:${built_tag}
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,38 @@ conda create -c rdkit -n my-rdkit-env rdkit
```
- Install mpi4py, networkx:
```bash
conda install mpi4py
pip install networkx=1.11
conda install -y mpi4py
pip install networkx==1.11
pip install matplotlib==3.5.3
```
- Install OpenAI baseline dependencies:
```bash
cd rl-baselines
pip install -e .
pip install -e rl-baselines
```
- Install customized molecule gym environment:
```bash
cd gym-molecule
pip install -e.
pip install -e gym-molecule
```

## Alternative Install instructions
For greater reproducibility a `Dockerfile` is provided that can be used to build an environment in which this code simply runs. To use this container environment download and install [Docker](https://www.docker.com/). To more easily reproduce the build and run steps install [Make](https://www.gnu.org/software/make/) and run the recipes provided in the [Makefile](Makefile).
- To build the Docker container:
```bash
make build
```
- To run this Docker container with/out a gpu while mounting the project into the running container:
```bash
make run_dev_{gpu}
```
- Enter the running container:
```bash
docker exec -it <container id> bash
```
- Activate conda environment and install project dependencies:
```bash
conda activate my-rdkit-env
bash install.sh
```

## Code description
There are 4 important files:
Expand Down
4 changes: 2 additions & 2 deletions gym-molecule/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

setup(name='gym-molecule',
version='0.0.1',
install_requires=['gym>=0.2.3', 'pandas']
)
install_requires=['gym==0.12.0', 'pandas']
)
7 changes: 7 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
conda install -y mpi4py
conda install -y -c rdkit rdkit
pip install networkx==1.11
pip install matplotlib==3.5.3
pip install -e rl-baselines
pip install -e gym-molecule
3 changes: 2 additions & 1 deletion rl-baselines/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
'progressbar2',
'mpi4py',
'cloudpickle',
'tensorflow>=1.4.0',
'tensorflow==1.13.1',
'tensorboardX==2.5.1',
'click',
],
description='OpenAI baselines: high quality implementations of reinforcement learning algorithms',
Expand Down