Skip to content

Add conda installation instructions #870

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

Merged
merged 5 commits into from
Mar 13, 2020
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
43 changes: 43 additions & 0 deletions docs/deployments/python-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,46 @@ git+https://<personal access token>@github.com/<username>/<repo name>.git@<tag o
```

You can generate a personal access token by following [these steps](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line).

## Conda packages

You can install Conda packages by creating a custom Docker image that first installs Conda and then installs your Conda packages.

Customize the template Dockerfile below with your desired Conda packages and follow these [instructions](./system-packages.md) to build and push your image to a container registry and configure Cortex to use your custom image.

```dockerfile
# Dockerfile

FROM <BASE CORTEX IMAGE>

# remove system-wide packages from the base image
RUN pip freeze > req && for pkg in "$(cat req)"; do pip uninstall $pkg -y || true; done && rm req

# add conda to path
ENV PATH /opt/conda/bin:$PATH

# install conda, it also includes py3.6.9
RUN curl https://repo.anaconda.com/miniconda/Miniconda3-4.7.12.1-Linux-x86_64.sh --output ~/miniconda.sh && \
/bin/bash ~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh && \
/opt/conda/bin/conda update conda && \
/opt/conda/bin/conda install --force python=3.6.9 && \
/opt/conda/bin/conda clean -tipsy && \
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
echo "conda activate base" >> ~/.bashrc

# install pip dependencies
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r /src/cortex/lib/requirements.txt && \
pip install --no-cache-dir -r /src/cortex/serve/requirements.txt

# ---------------------------------------------------------- #
# Install your Conda packages here
# RUN conda install --no-update-deps -c conda-forge rdkit

# ---------------------------------------------------------- #

# replace system python with conda's version
RUN sed -i 's/\/usr\/bin\/python3.6/\/opt\/conda\/bin\/python/g' /src/cortex/serve/run.sh
```
2 changes: 2 additions & 0 deletions docs/deployments/system-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ mkdir my-api && cd my-api && touch Dockerfile

The Docker images used to deploy your models are listed below. Based on the Cortex Predictor and compute type specified in your API configuration, choose a Cortex image to use as the base for your custom Docker image.

### Base Cortex images

<!-- CORTEX_VERSION_BRANCH_STABLE x5 -->
* Python (CPU): cortexlabs/python-serve:master
* Python (GPU): cortexlabs/python-serve-gpu:master
Expand Down