a-r-j / graphein

Protein Graph Library
https://graphein.ai/
MIT License
1.03k stars 131 forks source link

WIP: Add Dockerfile #69

Closed jadechip closed 2 years ago

jadechip commented 3 years ago

Details

FROM pytorch/pytorch:1.7.1-cuda11.0-cudnn8-runtime

I initially started from Ubuntu/Debian base images but quickly found that installing CUDA and the corresponding version of Pytorch can be troublesome, thus I opted to use the official Pytorch images as they come with CUDA, Pytorch and conda installed.

RUN apt-get update \
    && apt-get -y install build-essential ffmpeg libsm6 libxext6 wget git \
    && rm -rf /var/lib/apt/lists/*

These dependencies are required prerequisites.

ENV CONDA_ALWAYS_YES=true

This is simply sets the -y flag by default when installing Conda libs.

SHELL ["conda", "run", "-n", "graphein", "/bin/bash", "-c"]

There appear to be a couple of ways to enable a Conda environment in a Dockerfile, for a complete explanation of this approach please see this article.

RUN python -m ipykernel install --user --name=graphein

This simply installs ipykernel and makes the graphein Conda environment available within Jupiter notebooks.

RUN export TORCH=1.7.1 \
    && export CUDA=cu110 \
    && pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html \
    && pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html \
    && pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html \
    && pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html \
    && pip install torch-geometric

TODO: I believe it would be preferable to install torch-geommetric using RUN conda install pytorch-geometric -c rusty1s -c conda-forge -v but I haven't been able to get it to work due to libc related errors.

ENTRYPOINT ["conda", "run", "-n", "graphein", "jupyter", "notebook", "--notebook-dir=/opt/notebooks",  "--ip='*'", "--NotebookApp.token=''", "--NotebookApp.password=''", "--port=8888",  "--no-browser", "--allow-root"]

Running this Docker image starts a Jupiter notebook server without a password at localhost:8888.

What testing did you do to verify the changes in this PR?

I have verified that most examples from the main Graphein docs work using this setup, however further testing is advised. Especially when it comes to using CUDA.

sonarcloud[bot] commented 3 years ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

a-r-j commented 2 years ago

Hi @jadechip, have you tested/elaborated on this any? Do you think it's ready for a merge?