Skip to content

Commit 79d759e

Browse files
vishalbolludeliahu
authored andcommitted
Add conda installation instructions (#870)
(cherry picked from commit 890aac6)
1 parent cbc41d8 commit 79d759e

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

docs/deployments/python-packages.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,46 @@ git+https://<personal access token>@github.com/<username>/<repo name>.git@<tag o
8585
```
8686

8787
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).
88+
89+
## Conda packages
90+
91+
You can install Conda packages by creating a custom Docker image that first installs Conda and then installs your Conda packages.
92+
93+
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.
94+
95+
```dockerfile
96+
# Dockerfile
97+
98+
FROM <BASE CORTEX IMAGE>
99+
100+
# remove system-wide packages from the base image
101+
RUN pip freeze > req && for pkg in "$(cat req)"; do pip uninstall $pkg -y || true; done && rm req
102+
103+
# add conda to path
104+
ENV PATH /opt/conda/bin:$PATH
105+
106+
# install conda, it also includes py3.6.9
107+
RUN curl https://repo.anaconda.com/miniconda/Miniconda3-4.7.12.1-Linux-x86_64.sh --output ~/miniconda.sh && \
108+
/bin/bash ~/miniconda.sh -b -p /opt/conda && \
109+
rm ~/miniconda.sh && \
110+
/opt/conda/bin/conda update conda && \
111+
/opt/conda/bin/conda install --force python=3.6.9 && \
112+
/opt/conda/bin/conda clean -tipsy && \
113+
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
114+
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
115+
echo "conda activate base" >> ~/.bashrc
116+
117+
# install pip dependencies
118+
RUN pip install --upgrade pip && \
119+
pip install --no-cache-dir -r /src/cortex/lib/requirements.txt && \
120+
pip install --no-cache-dir -r /src/cortex/serve/requirements.txt
121+
122+
# ---------------------------------------------------------- #
123+
# Install your Conda packages here
124+
# RUN conda install --no-update-deps -c conda-forge rdkit
125+
126+
# ---------------------------------------------------------- #
127+
128+
# replace system python with conda's version
129+
RUN sed -i 's/\/usr\/bin\/python3.6/\/opt\/conda\/bin\/python/g' /src/cortex/serve/run.sh
130+
```

docs/deployments/system-packages.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ mkdir my-api && cd my-api && touch Dockerfile
1212

1313
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.
1414

15+
### Base Cortex images
16+
1517
<!-- CORTEX_VERSION_BRANCH_STABLE x5 -->
1618
* Python (CPU): cortexlabs/python-serve:0.14.1
1719
* Python (GPU): cortexlabs/python-serve-gpu:0.14.1

0 commit comments

Comments
 (0)