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 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
35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,41 @@ 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.
For running on CPU, simply run the docker container:
```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
make install
```

## 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
16 changes: 16 additions & 0 deletions devel-cpu.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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
#COPY requirements.txt test_requirements.txt tmp/
COPY . /tmp
WORKDIR /tmp
# install requirements
#RUN python3 -m pip --no-cache-dir install -r tmp/requirements.txt

# install test requirements which also installs requirements.txt
RUN python3 -m pip --no-cache-dir install -r test_requirements.txt

RUN python3 -m pip --no-cache-dir install ".[pytorch]"
14 changes: 14 additions & 0 deletions devel-gpu.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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
# Copy all files to container as intalling .[pytorch] requires setup.py, which requires other files
COPY . /tmp
WORKDIR /tmp

# install test requirements which also installs requirements.txt
RUN python3 -m pip --no-cache-dir install -r test_requirements.txt

RUN python3 -m pip --no-cache-dir install ".[pytorch]"
1 change: 0 additions & 1 deletion test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ 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 # not directly required, pinned by Snyk to avoid a vulnerability