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

Add Dockerfiles for development on CPU and GPU #163

Merged
merged 7 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,40 @@ This command will only work on Unix-like systems and requires `pandoc` to be ins

> ❗ Running `make build-docs` in a Python 3.5 environment may sometimes yield multiple warning messages like the following: `WARNING: toctree contains reference to nonexisting document '04_user_guide/04_user_guide'`. You can simply ignore them or switch to Python 3.6+ when building documentation.

## Developing in Docker
GabrielAzevedoFerreiraQB marked this conversation as resolved.
Show resolved Hide resolved
The Docker images have all the necessary dependencies built in. To develop using the docker containers do the following

1. Build the necessary container
```bash
export CONTAINER_TYPE='cpu' # or gpu
docker build -t quantumblacklabs/causalnex:devel-$CONTAINER_TYPE -f devel-$CONTAINER_TYPE.Dockerfile .
```

2. Run the container in interactive mode.
```bash
GabrielAzevedoFerreiraQB marked this conversation as resolved.
Show resolved Hide resolved
docker run -it -w /causalnex_src -v $PWD:/causalnex_src quantumblacklabs/causalnex:devel-cpu bash
```

For the `gpu` type your host machine needs access to a GPU with the CUDA driver installed. The `devel-gpu` image will be able to access the gpu on the host
```bash
docker run --gpus all -it -w /causalnex_src -v $PWD:/causalnex_src quantumblacklabs/causalnex:devel-gpu bash
```

3. Run tests
```bash
make test
```

4. If all tests pass you can build the wheel
```bash
make package
```

5. Now you can install the pip package that has your changes in either the container or on your host machine. The name of installed package will be `causalnex`
```bash
pip install dist/causalnex-0.11.0-py3-none-any.whl
```
GabrielAzevedoFerreiraQB marked this conversation as resolved.
Show resolved Hide resolved

## Hints on pre-commit usage
The checks will automatically run on all the changed files on each commit.
Even more extensive set of checks (including the heavy set of `pylint` checks)
Expand Down
58 changes: 58 additions & 0 deletions devel-cpu.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update -y && apt install -y python3.8 python3-pip libgraphviz-dev graphviz

RUN ln -s $(which python3) /usr/local/bin/python

# install requirements
RUN python3 -m pip --no-cache-dir install \
'networkx~=2.5' \
'numpy>=1.14.2, <2.0' \
'pandas>=1.0, <2.0' \
'pathos>=0.2.7, <0.3.0' \
'pgmpy>=0.1.12, <0.2.0' \
'scikit-learn>=0.22.0, <0.25.0, !=0.22.2.post1, !=0.24.1' \
'scipy>=1.2.0, <1.7' \
'torch>=1.7, <2.0' \
'wrapt>=1.11.0, <1.13'
GabrielAzevedoFerreiraQB marked this conversation as resolved.
Show resolved Hide resolved

# install test requirements
RUN python3 -m pip --no-cache-dir install \
'Cython>=0.29, <1.0' \
'flake8>=3.5, <4.0' \
'ipython>=7.0, <7.17' \
'isort>=4.3.16, <5.0' \
'matplotlib~=3.3' \
'mdlp-discretization~=0.3.3' \
'mock>=2.0.0, <3.0' \
'pre-commit>=2.9.2' \
'pygraphviz>=1.5, <2.0' \
'pylint>=2.7.2, <3.0' \
'pytest-cov>=2.5, <3.0' \
'pytest-mock>=1.7.1,<2.0' \
'pytest>=4.3.0,<5.0' \
'scikit-learn>=0.24.2'

# install doc requirements
RUN python3 -m pip --no-cache-dir install \
GabrielAzevedoFerreiraQB marked this conversation as resolved.
Show resolved Hide resolved
'click>=7.0, <8.0' \
'ipykernel>=4.8.1, <5.0' \
'ipython_genutils>=0.2.0' \
'jinja2>=2.3, <3.0' \
'jupyter_client>=5.1, <7.0' \
'Markupsafe<2.1' \
'nbconvert>=5.0, <6.0' \
'nbsphinx==0.4.2' \
'nbstripout==0.3.3' \
'patchy>=1.5, <2.0' \
'pydot>=1.4, <2.0' \
'pygments>=2.6.1, <3.0' \
'pygraphviz>=1.5, <2.0' \
'recommonmark>=0.5.0, <1.0' \
'sphinx-autodoc-typehints>=1.6.0, <2.0' \
'sphinx-markdown-tables>=0.0.15, <1.0' \
'sphinx>=3.0.4, <4.0' \
'sphinx_copybutton>=0.2.5, <1.0' \
'sphinx_rtd_theme>=0.4.3, <1.0'
58 changes: 58 additions & 0 deletions devel-gpu.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM nvidia/cuda:11.7.0-base-ubuntu20.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update -y && apt install -y python3.8 python3-pip libgraphviz-dev graphviz

RUN ln -s $(which python3) /usr/local/bin/python

# install requirements
RUN python3 -m pip --no-cache-dir install \
'networkx~=2.5' \
'numpy>=1.14.2, <2.0' \
'pandas>=1.0, <2.0' \
'pathos>=0.2.7, <0.3.0' \
'pgmpy>=0.1.12, <0.2.0' \
'scikit-learn>=0.22.0, <0.25.0, !=0.22.2.post1, !=0.24.1' \
'scipy>=1.2.0, <1.7' \
'torch>=1.7, <2.0' \
'wrapt>=1.11.0, <1.13'

# install test requirements
RUN python3 -m pip --no-cache-dir install \
'Cython>=0.29, <1.0' \
'flake8>=3.5, <4.0' \
'ipython>=7.0, <7.17' \
'isort>=4.3.16, <5.0' \
'matplotlib~=3.3' \
'mdlp-discretization~=0.3.3' \
'mock>=2.0.0, <3.0' \
'pre-commit>=2.9.2' \
'pygraphviz>=1.5, <2.0' \
'pylint>=2.7.2, <3.0' \
'pytest-cov>=2.5, <3.0' \
'pytest-mock>=1.7.1,<2.0' \
'pytest>=4.3.0,<5.0' \
'scikit-learn>=0.24.2'

# install doc requirements
RUN python3 -m pip --no-cache-dir install \
'click>=7.0, <8.0' \
'ipykernel>=4.8.1, <5.0' \
'ipython_genutils>=0.2.0' \
'jinja2>=2.3, <3.0' \
'jupyter_client>=5.1, <7.0' \
'Markupsafe<2.1' \
'nbconvert>=5.0, <6.0' \
'nbsphinx==0.4.2' \
'nbstripout==0.3.3' \
'patchy>=1.5, <2.0' \
'pydot>=1.4, <2.0' \
'pygments>=2.6.1, <3.0' \
'pygraphviz>=1.5, <2.0' \
'recommonmark>=0.5.0, <1.0' \
'sphinx-autodoc-typehints>=1.6.0, <2.0' \
'sphinx-markdown-tables>=0.0.15, <1.0' \
'sphinx>=3.0.4, <4.0' \
'sphinx_copybutton>=0.2.5, <1.0' \
'sphinx_rtd_theme>=0.4.3, <1.0'