-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
docker file and compose #120
Changes from 15 commits
6700b0c
77ae648
df37b09
dff73aa
1a5c7dc
68210a9
b4f09d5
a29a7a3
47cded9
e5b33af
03ddd51
41c26b9
b7c6db5
59482a6
c3b465c
52de272
d4cfac2
06cce6f
aaf8a79
22c5f60
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,20 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#FROM python:3.10.11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#FROM wallies/python-cuda:3.10-cuda11.6-runtime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Using argument for base image to avoid multiplying Dockerfiles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ARG BASEIMAGE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FROM $BASEIMAGE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RUN groupadd -g 10009 -o privategpt && useradd -m -u 10009 -g 10009 -o -s /bin/bash privategpt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
USER privategpt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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. Tried running ingest docker container in linux and getting this error:
googling it suggests that its related to the Dockerfile USER not having correct permissions, but I'm not sure. Do you know what could be causing this? I ran it fine on windows through wsl2 docker desktop, but get this error when running on a linux machine. 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. It's related to the fact that you're running the docker container as root, and the unpriviliged container user can't create directories as root. For this particular error 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. thank you, that fixed it. maybe worth noting in the readme? not sure how many other people will get this |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
WORKDIR /home/privategpt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
COPY ./src/requirements.txt src/requirements.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ARG LLAMA_CMAKE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#RUN CMAKE_ARGS="-DLLAMA_OPENBLAS=on" FORCE_CMAKE=1 pip install $(grep llama-cpp-python src/requirements.txt) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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. ♻️
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RUN ( /bin/bash -c "${LLAMA_CMAKE} pip install \$(grep llama-cpp-python src/requirements.txt)" 2>&1 | tee llama-build.log ) && sleep 10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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. I forgot the remove the This |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RUN pip install --no-cache-dir -r src/requirements.txt 2>&1 | tee pip-install.log | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
COPY ./src src | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Suggested change
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. Proposed update in PR :JulienA#2 . |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# ENTRYPOINT ["python", "src/privateGPT.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. ♻️
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,5 +104,41 @@ To install a C++ compiler on Windows 10/11, follow these steps: | |
3. Download the MinGW installer from the [MinGW website](https://sourceforge.net/projects/mingw/). | ||
4. Run the installer and select the `gcc` component. | ||
|
||
## Docker Version | ||
|
||
1. Put your data in models / source_documents in the project root folder (Can be customized changing the corresponding value in the docker-compose.yaml) | ||
|
||
2. You can ingest your data using the docker-compose | ||
|
||
1. Without Cuda | ||
|
||
```sh | ||
docker compose run --rm --build privategpt-ingest | ||
``` | ||
|
||
2. With Cuda 11.6 or 11.7 | ||
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. Maybe add a note: :warning: The use of CUDA is not fully validated yet. Also the CUDA version on your host is important and must be at least the version used in the container. You can check your version with `docker compose run --rm --build check-cuda-version`
:information_source: Get a recent CUDA version from https://developer.nvidia.com/cuda-downloads. |
||
|
||
```sh | ||
docker compose run --rm --build privategpt-cuda-11.6-ingest | ||
|
||
docker compose run --rm --build privategpt-cuda-11.7-ingest | ||
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. I get an error when running this command, not sure if its related to docker compose version?
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. I am on Win11 and the flag is ok with (tested from a powershell prompt)
Added in Docker compose 2.13.0 docker/docs@b00b1d2 . 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. Thanks
after doing a build, it runs and give this error:
I see 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. This branch needs a merge from main. You can do this locally for now:
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. rebuilt and its working 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. I also received this error, I think it's a red herring due to the output of Solution to prevent this would be to remove the pipe into the log file within |
||
``` | ||
|
||
3. You can run **after** ingesting your data or using an **existing db** with the docker-compose | ||
|
||
1. Without Cuda | ||
|
||
```sh | ||
docker compose run --rm --build privategpt | ||
``` | ||
|
||
2. With Cuda 11.6 or 11.7 | ||
|
||
```sh | ||
docker compose run --rm --build privategpt-cuda-11.6 | ||
|
||
docker compose run --rm --build privategpt-cuda-11.7 | ||
``` | ||
|
||
# Disclaimer | ||
This is a test project to validate the feasibility of a fully private solution for question answering using LLMs and Vector embeddings. It is not production ready, and it is not meant to be used in production. The models selection is not optimized for performance, but for privacy; but it is possible to use different models and vectorstores to improve performance. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* | ||
!.gitignore | ||
!.gitkeep |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
--- | ||
version: '3.9' | ||
services: | ||
# | ||
# Base service, without CUDA | ||
# | ||
privategpt: | ||
build: | ||
context: . | ||
dockerfile: ./Dockerfile | ||
args: [ --rm, "BASEIMAGE=python:3.10.11", LLAMA_CMAKE= ] | ||
image: privategpt:test | ||
command: [ python, src/privateGPT.py ] | ||
environment: | ||
- PERSIST_DIRECTORY=${PERSIST_DIRECTORY:-/home/privategpt/db} | ||
- LLAMA_EMBEDDINGS_MODEL=${LLAMA_EMBEDDINGS_MODEL:-/home/privategpt/models/ggml-model-q4_0.bin} | ||
- EMBEDDINGS_MODEL_NAME=${EMBEDDINGS_MODEL_NAME:-all-MiniLM-L6-v2} | ||
- MODEL_TYPE=${MODEL_TYPE:-GPT4All} | ||
- MODEL_PATH=${MODEL_PATH:-/home/privategpt/models/ggml-gpt4all-j-v1.3-groovy.bin} | ||
- MODEL_N_CTX=${MODEL_N_CTX:-1000} | ||
volumes: | ||
- ${CACHE_MOUNT:-./cache}:/home/privategpt/.cache/torch | ||
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. The local .cache may be populated with other subdirectories, so mapping that entire directory to torch is not ok. This is wy I mapped only the "torch" directory where the models seem to be downloaded and I mapped it from a "cache" directory int he models path, because this is essentially a cache of models. To avoid having extra patch to specify, I did not add another path such ass "MODEL_CACHE_MOUNT". |
||
- ${MODEL_MOUNT:-./models}:/home/privategpt/models | ||
- ${PERSIST_MOUNT:-./db}:/home/privategpt/db | ||
|
||
# | ||
# To run with CUDA 11.6 | ||
# | ||
# docker compose run --rm --build privategpt-cuda-11.6 | ||
# | ||
privategpt-cuda-11.6: | ||
extends: privategpt | ||
image: privategpt:cuda-11.6 | ||
build: | ||
args: | ||
- BASEIMAGE=wallies/python-cuda:3.10-cuda11.6-runtime | ||
- LLAMA_CMAKE=CMAKE_ARGS='-DLLAMA_OPENBLAS=on' FORCE_CMAKE=1 | ||
deploy: | ||
resources: | ||
reservations: | ||
devices: | ||
- driver: nvidia | ||
count: 1 | ||
capabilities: [ gpu ] | ||
|
||
# | ||
# To run with CUDA 11.7 | ||
# | ||
# docker compose run --rm --build privategpt-cuda-11.7 | ||
# | ||
privategpt-cuda-11.7: | ||
extends: privategpt-cuda-11.6 | ||
image: privategpt:cuda-11.7 | ||
build: | ||
args: [ "BASEIMAGE=wallies/python-cuda:3.10-cuda11.7-runtime" ] | ||
|
||
# | ||
# For ingest without cuda: | ||
# | ||
# docker compose run --rm --build privategpt-ingest | ||
# | ||
privategpt-ingest: | ||
extends: privategpt | ||
command: [ python, src/ingest.py ] | ||
environment: | ||
- SOURCE_DIRECTORY=${SOURCE_DIRECTORY:-/home/privategpt/source_documents} | ||
volumes: | ||
- ${SOURCE_MOUNT:-./source_documents}:/home/privategpt/source_documents | ||
|
||
# | ||
# To ingest using cuda 11.6: | ||
# | ||
# docker compose run --rm --build privategpt-cuda-11.6-ingest | ||
# | ||
privategpt-cuda-11.6-ingest: | ||
extends: privategpt-cuda-11.6 | ||
image: privategpt:cuda-11.6 | ||
command: [ python, src/ingest.py ] | ||
environment: | ||
- SOURCE_DIRECTORY=${SOURCE_DIRECTORY:-/home/privategpt/source_documents} | ||
volumes: | ||
- ${SOURCE_MOUNT:-./source_documents}:/home/privategpt/source_documents | ||
|
||
# | ||
# To ingest using cuda 11.7: | ||
# | ||
# docker compose run --rm --build privategpt-cuda-11.7-ingest | ||
# | ||
privategpt-cuda-11.7-ingest: | ||
extends: privategpt-cuda-11.7 | ||
image: privategpt:cuda-11.7 | ||
command: [ python, src/ingest.py ] | ||
environment: | ||
- SOURCE_DIRECTORY=${SOURCE_DIRECTORY:-/home/privategpt/source_documents} | ||
volumes: | ||
- ${SOURCE_MOUNT:-./source_documents}:/home/privategpt/source_documents | ||
|
||
# Check your system's version using | ||
# | ||
# docker compose run --rm check-cuda-version | ||
# | ||
# then build and test the privateGPT container | ||
# using | ||
# | ||
# docker compose run --rm check-cuda-<CUDAVERSION> | ||
# | ||
# Where <CUDAVERSION> is the version you found using 'check-cuda-version'. | ||
# | ||
# Example if CUDAVERSION == 11.6 | ||
# | ||
# docker compose run --rm --build check-cuda-11.6 | ||
# | ||
# | ||
# | ||
# You can update your host's CUDA installation by downloading | ||
# a recent version from | ||
# | ||
# https://developer.nvidia.com/cuda-downloads . | ||
# | ||
|
||
check-cuda-version: | ||
image: ubuntu | ||
command: [ nvidia-smi ] | ||
check-cuda-11.6: | ||
extends: privategpt-cuda-11.6 | ||
command: [ nvidia-smi ] | ||
check-cuda-11.7: | ||
extends: privategpt-cuda-11.7 | ||
command: [ nvidia-smi ] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* | ||
!.gitignore | ||
!.gitkeep |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* | ||
!.gitignore | ||
!.gitkeep |
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.
♻️