-
Notifications
You must be signed in to change notification settings - Fork 44
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 the initial docker file #51
Changes from 6 commits
558bbe6
d12f84e
75b31ae
37e7332
1f3b0b7
558ec35
fc0fe99
08ce6be
cd429b3
19641f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Overview | ||
In this folder, we create the different dockerfiles for using pykoi. | ||
|
||
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. | ||
|
||
To run a docker container, we can use the following command: | ||
```bash | ||
docker run -dp 5000:5000 -v $(pwd)/app.py:/app/app.py \ | ||
--name alex_test \ | ||
weialexchen/pykoi-cpu:app | ||
``` | ||
|
||
Note that we need to keep the exposed port as 5000 (default value) to make the server work. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM weialexchen/pykoi-cpu:base | ||
|
||
# set the working directory in the container | ||
WORKDIR /app | ||
|
||
# copy the content | ||
COPY . /app | ||
|
||
# Expose the port on which the app will be running | ||
EXPOSE 5000 | ||
|
||
# For dev | ||
CMD ["python", "app.py"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: add an empty line at the end of dockerfile There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DONE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Demo for the chatbot application using OpenAI endpoint.""" | ||
import pykoi | ||
|
||
########################################################## | ||
# Creating an OpenAI model (requires an OpenAI API key) # | ||
########################################################## | ||
# enter openai api key here | ||
api_key = "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" | ||
|
||
# Creating an OpenAI model | ||
model = pykoi.ModelFactory.create_model( | ||
model_source="openai", | ||
api_key=api_key) | ||
|
||
##################################### | ||
# Creating a chatbot with the model # | ||
##################################### | ||
database = pykoi.QuestionAnswerDatabase(debug=True) | ||
chatbot = pykoi.Chatbot(model=model, feedback="vote") | ||
# chatbot = pykoi.Chatbot(model=model, feedback="rank") | ||
dashboard = pykoi.Dashboard(database=database) | ||
|
||
########################################################### | ||
# Starting the application and add chatbot as a component # | ||
########################################################### | ||
# Create the application | ||
# app = pykoi.Application(debug=False, share=True) | ||
app = pykoi.Application( | ||
host='0.0.0.0', | ||
alexchen4ai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
debug=False, | ||
share=True) | ||
app.add_component(chatbot) | ||
app.add_component(dashboard) | ||
app.run() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM python:3.10 | ||
LABEL maintainer="Pykio Team" | ||
LABEL repository="Pykoi" | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt update && \ | ||
apt install -y bash \ | ||
build-essential \ | ||
git \ | ||
git-lfs \ | ||
curl \ | ||
ca-certificates \ | ||
libsndfile1-dev | ||
|
||
# make sure to use venv | ||
RUN python -m venv /opt/venv | ||
ENV PATH="/opt/venv/bin:$PATH" | ||
|
||
# pre-install the heavy dependencies (these can later be overridden by the deps from setup.py) | ||
# follow the instructions here: https://cloud.google.com/tpu/docs/run-in-container#train_a_jax_model_in_a_docker_container | ||
RUN python -m pip install --no-cache-dir --upgrade pip && \ | ||
python -m pip install --upgrade --no-cache-dir \ | ||
pykoi | ||
|
||
CMD ["/bin/bash"] | ||
alexchen4ai marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
FROM python:3.10 | ||
LABEL maintainer="Pykio Team" | ||
LABEL repository="Pykoi" | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt update && \ | ||
apt install -y bash \ | ||
build-essential \ | ||
git \ | ||
git-lfs \ | ||
curl \ | ||
ca-certificates \ | ||
libsndfile1-dev \ | ||
libgl1 | ||
|
||
# make sure to use venv | ||
RUN python3 -m venv /opt/venv | ||
ENV PATH="/opt/venv/bin:$PATH" | ||
|
||
# pre-install the heavy dependencies (these can later be overridden by the deps from setup.py) | ||
RUN python3 -m pip install --no-cache-dir --upgrade pip && \ | ||
python3 -m pip install --no-cache-dir \ | ||
torch \ | ||
torchvision \ | ||
torchaudio && \ | ||
python3 -m pip install --no-cache-dir \ | ||
accelerate \ | ||
datasets \ | ||
hf-doc-builder \ | ||
huggingface-hub \ | ||
Jinja2 \ | ||
librosa \ | ||
numpy \ | ||
scipy \ | ||
tensorboard \ | ||
transformers \ | ||
omegaconf \ | ||
pytorch-lightning \ | ||
xformers \ | ||
pykoi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for the gpu version: I think we only need to install?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but for using huggingface model, more packages/library is needed. I will only keep the torch one. |
||
|
||
CMD ["/bin/bash"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: add an empty line at the end of dockerfile There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DONE |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
# Creating an OpenAI model (requires an OpenAI API key) # | ||
########################################################## | ||
# enter openai api key here | ||
api_key = "" | ||
api_key = "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" | ||
|
||
# Creating an OpenAI model | ||
model = pykoi.ModelFactory.create_model( | ||
|
@@ -25,7 +25,9 @@ | |
########################################################### | ||
# Create the application | ||
# app = pykoi.Application(debug=False, share=True) | ||
app = pykoi.Application(debug=False, share=False) | ||
app = pykoi.Application( | ||
debug=False, | ||
share=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we can revert all these changes and leave boilerplate code as before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
app.add_component(chatbot) | ||
app.add_component(dashboard) | ||
app.run() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import gradio as gr | ||
|
||
def greet(name): | ||
return "Hello " + name + "!" | ||
|
||
demo = gr.Interface(fn=greet, inputs="text", outputs="text") | ||
|
||
demo.launch() | ||
alexchen4ai marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: considering that we have not push the docker images into the docker hub, we can add below steps regarding how your build docker images.
docker/pykoi-cpu/Dockerfile
into docker image"weialexchen/pykoi-cpu:base"
docker/pykoi-cpu-custom/Dockerfile
into docker imageweialexchen/pykoi-cpu:app
nit: change we change
weialexchen
topykoi
, so we can push them into dockerhub easily later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, please create a pykoi docker account then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dm you with the dockerhub account and access token for dockerhub push