visual-chatgpt icon indicating copy to clipboard operation
visual-chatgpt copied to clipboard

Dockerfile

Open danstarns opened this issue 2 years ago • 6 comments

Please could you add a docker file for this project? I have been trying to add one but having issues related to:

  • https://github.com/microsoft/visual-chatgpt/issues/37
  • https://github.com/microsoft/visual-chatgpt/issues/33
  • https://github.com/microsoft/visual-chatgpt/issues/19

danstarns avatar Mar 10 '23 13:03 danstarns

I imagine this would help windows users too:

  • https://github.com/microsoft/visual-chatgpt/issues/20
  • https://github.com/microsoft/visual-chatgpt/issues/38

danstarns avatar Mar 10 '23 13:03 danstarns

Here are the two I have tried:

# Start with the official PyTorch image
FROM pytorch/pytorch:1.10.0-cuda11.3-cudnn8-runtime

# Set the working directory
WORKDIR /app

# Install necessary packages
RUN apt-get update && apt-get install -y \
    ffmpeg \
    libsm6 \
    libxext6 \
    libfontconfig1 \
    libxrender1 \
    && rm -rf /var/lib/apt/lists/*

# Copy files to the working directory
COPY visual_chatgpt.py requirement.txt download.sh ./

# Create a new environment and install dependencies
RUN conda create -n visgpt python=3.8 && \
    echo "conda activate visgpt" >> ~/.bashrc && \
    /bin/bash -c "source ~/.bashrc" && \
    pip install --no-cache-dir -r requirement.txt && \
    bash download.sh && \
    conda clean --all --yes && \
    rm -rf /opt/conda/pkgs/*

# Set an environment variable for the OpenAI API key
ENV OPENAI_API_KEY=${OPENAI_API_KEY}

# Create a new directory for the generated images
RUN mkdir /app/image && chmod 777 /app/image

# Start the application
CMD ["bash", "-c", "python visual_chatgpt.py"]
FROM python:3.8-slim-buster

WORKDIR /app

COPY visual_chatgpt.py requirement.txt download.sh ./

RUN apt-get update && \
    apt-get install -y git && \
    pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirement.txt && \
    bash download.sh && \
    apt-get remove -y git && \
    apt-get autoremove -y && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENV OPENAI_API_KEY=${OPENAI_API_KEY}

RUN mkdir /app/image && chmod 777 /app/image

CMD ["bash", "-c", "python visual_chatgpt.py"]

danstarns avatar Mar 10 '23 13:03 danstarns

do they work? why two docker files?

Also the download.sh should be optional because its like 40GB of download. better bind the folder and maybe let users copy models manually or link them or whatever.

Do these dockerfiles work on windows? i havent tried it.

andzejsp avatar Mar 10 '23 15:03 andzejsp

@andzejsp I think that @danstarns wanted to try both pip and conda environments. That's why he's provided two Dockerfiles. Why don't you try it by yourself on Windows?

sinwoobang avatar Mar 12 '23 18:03 sinwoobang

Just to add my 2 cents, I am still testing it though. Tried resolving the OpenCV version issue https://github.com/microsoft/visual-chatgpt/issues/50.

FROM python:3.8-slim-buster

ENV OPENAI_API_KEY=${OPENAI_API_KEY}
ENV PYTHONFAULTHANDLER=1 \
    PYTHONHASHSEED=random \
    PYTHONUNBUFFERED=1

RUN apt-get update -y
RUN apt-get install -y git curl wget

RUN git clone https://github.com/microsoft/visual-chatgpt.git

WORKDIR /visual-chatgpt/

RUN pip install --upgrade pip
RUN pip install opencv-python
RUN sed '/opencv/d' requirement.txt > requirement.txt
RUN pip install -r requirement.txt
RUN bash download.sh

RUN mkdir /visual-chatgpt/image && chmod 777 /visual-chatgpt/image

CMD ["bash", "-c", "python", "visual_chatgpt.py"]

sinwoobang avatar Mar 12 '23 18:03 sinwoobang

Anyone managed to run the newest version in docker?

mosheliv avatar Apr 23 '23 00:04 mosheliv