Skip to content

Commit

Permalink
Merge pull request #91 from CambioML/jojo-branch
Browse files Browse the repository at this point in the history
move Dockerfile to docker folder and update docker README
  • Loading branch information
jojortz authored Nov 22, 2023
2 parents 6f48897 + 028a88d commit 19e5789
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
24 changes: 21 additions & 3 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To run a `pykoi` Docker container, launch a GPU instance with the following conf
- Deep Learning AMI PyTorch GPU 2.0.1 (Ubuntu 20.04)
<img src="../example/image/readme_ec2_ami.jpg" alt="Alt text" width="75%" height="75%"/>
- EBS: at least 100G

<img src="../example/image/readme_ec2_storage.png" alt="Alt text" width="50%" height="50%"/>

### Installing Docker on your EC2
Expand Down Expand Up @@ -146,10 +146,28 @@ docker rm [CONTAINER_NAME]
```
# Building Custom Docker Images
In this folder, we create the different dockerfiles for using pykoi.
In this folder, we have the different Dockerfiles for using `pykoi`.
## Building from the Repo
Some of these examples build from the pykoi repository. For example, you can reference the Dockerfile in the `pykoi-retrieval-huggingface`.
In order to build the docker image, first ensure you are in the base directory of the `pykoi` repo. __You will encounter errors if you're not in the base directory__
Then, you can run the following command:
```
docker build -t [name]:[tag] . -f [file_path_to_dockerfile]
```
Here's and example of building the `pykoi-retrieval-huggingface` Dockerfile.
```
docker build -t pykoi:0.1 . -f docker/pykoi-retrieval-huggingface/Dockerfile
```
## Building based on pykoi library
There are also examples to build based on the `pykoi` package. These examples install `pykoi` via `pip` and run different applications from there. This relies on the latest pypi released versions.
1. `pykoi-cpu`: The base image for the cpu-based usage.
2. `pykoi-cpu-custom`: When you run this docker image, try to modify the `app.py` and mount it when running the docker container.
1. `pykoi-cpu-custom`: When you run this docker image, try to modify the `app.py` and mount it when running the docker container.
To run a docker container, we can use the following command:
```bash
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile → ...er/pykoi-retrieval-huggingface/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use a Python base image
FROM python:3.10
FROM pytorch/pytorch:2.1.1-cuda12.1-cudnn8-runtime

# Set working directory
WORKDIR /app/
Expand All @@ -17,19 +17,20 @@ RUN pip install poetry
# Copy only necessary project files into the container
COPY pyproject.toml poetry.lock /app/


# Install project dependencies using Poetry
RUN poetry config virtualenvs.create false \
&& poetry install --no-root --extras "rag huggingface" \
&& pip uninstall -y torch \
&& pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu121 \
&& pip uninstall -y torchvision \
&& rm -rf /root/.cache/


# Copy the project files into the container
COPY example /app/example
COPY pykoi /app/pykoi

# Set the necessary environment variables to enable GPU
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
ENV RETRIEVAL_MODEL=databricks/dolly-v2-3b

# Set entrypoint to run your command
Expand Down

0 comments on commit 19e5789

Please sign in to comment.