From 4fde9c30da54e90df0a463d20cabc2faabbc7f5a Mon Sep 17 00:00:00 2001 From: realies <5107843+realies@users.noreply.github.com> Date: Sun, 3 Dec 2023 19:28:27 +0200 Subject: [PATCH 1/3] add dockerfile, update readme --- Dockerfile | 7 +++++++ readme.md | 15 +++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..8b143571b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 +RUN apt-get update && apt-get install -y python3-pip git libgl1-mesa-glx libglib2.0-0 +COPY . /app +WORKDIR /app +RUN pip3 install -r requirements_versions.txt +RUN pip3 install --extra-index-url https://download.pytorch.org/whl/cu121 torch==2.1.0 torchvision==0.16.0 +CMD ["python3", "entry_with_update.py", "--listen"] diff --git a/readme.md b/readme.md index ab59d872a..e3c911fc8 100644 --- a/readme.md +++ b/readme.md @@ -120,6 +120,21 @@ Note that this Colab will disable refiner by default because Colab free's resour Thanks to [camenduru](https://github.com/camenduru)! +### Linux (Using Docker + Nvidia GPU) + +``` +git clone https://github.com/lllyasviel/Fooocus.git +cd Fooocus +docker build . -t fooocus +docker run -d --name=fooocus \ + -e NVIDIA_DRIVER_CAPABILITIES=compute,utility \ + -e NVIDIA_VISIBLE_DEVICES=all \ + -v /local/folder/fooocus/models:/app/models \ + -v /local/folder/fooocus/outputs:/app/outputs \ + -p 7865:7865 \ + --runtime=nvidia fooocus +``` + ### Linux (Using Anaconda) If you want to use Anaconda/Miniconda, you can From 5a3fdef9b26b0ceb31daba0ce8d6ce9fb2308f39 Mon Sep 17 00:00:00 2001 From: realies <5107843+realies@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:58:33 +0200 Subject: [PATCH 2/3] drop app user privileges --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index 8b143571b..666d86c9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,4 +4,8 @@ COPY . /app WORKDIR /app RUN pip3 install -r requirements_versions.txt RUN pip3 install --extra-index-url https://download.pytorch.org/whl/cu121 torch==2.1.0 torchvision==0.16.0 +RUN useradd -u 1000 -U -d /app -s /bin/false fooocus && \ + usermod -G users fooocus && \ + chown -R 1000:1000 /app +USER fooocus CMD ["python3", "entry_with_update.py", "--listen"] From b4f170cae58511975c51c8cd36fc67f74fd8c4f7 Mon Sep 17 00:00:00 2001 From: realies <5107843+realies@users.noreply.github.com> Date: Mon, 11 Dec 2023 17:09:23 +0200 Subject: [PATCH 3/3] reduce image size --- Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 666d86c9e..b23dd5862 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,11 @@ FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 -RUN apt-get update && apt-get install -y python3-pip git libgl1-mesa-glx libglib2.0-0 +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3-pip git libgl1-mesa-glx libglib2.0-0 && \ + apt-get clean && rm -rf /var/lib/apt/lists/* COPY . /app WORKDIR /app -RUN pip3 install -r requirements_versions.txt -RUN pip3 install --extra-index-url https://download.pytorch.org/whl/cu121 torch==2.1.0 torchvision==0.16.0 +RUN pip3 install --no-cache-dir -r requirements_versions.txt \ + torch==2.1.0 torchvision==0.16.0 --extra-index-url https://download.pytorch.org/whl/cu121 RUN useradd -u 1000 -U -d /app -s /bin/false fooocus && \ usermod -G users fooocus && \ chown -R 1000:1000 /app