Merge pull request #212 from MrForExample/dev

Add Docker Instructions
This commit is contained in:
Mr. For Example
2024-07-12 15:10:49 -06:00
committed by GitHub
8 changed files with 283 additions and 124 deletions
+4 -1
View File
@@ -165,4 +165,7 @@ outputs/
# Ignore folders only used for build dependencies
_Pre_Builds/_Build_Dependencies
_Pre_Builds/_Build_Wheels
_Pre_Builds/_Libs
_Pre_Builds/_Libs
models/
output/
+86
View File
@@ -0,0 +1,86 @@
## Docker Instructions
This document contains instructions on how to build and run the application using Docker.
### Disclaimer
These instructions are based on the assumption that you have Docker installed on your machine. If you don't have Docker installed, you can download it from the [official website](https://www.docker.com/get-started).
All tests were performed using Docker version 26.1.3 and Docker Compose version 2.27.0 under Ubuntu 22.04.
These instructions are focused on running the Unique3D workflows, you can use the same steps to run the other workflows, but you need to check the model requirements for each workflow at the [README.md](../README.md) file.
### Requirements
You need the `nvidia-container-runtime` installed and configured to run the application. You can check the installation instructions at the [official documentation](https://developer.nvidia.com/container-runtime).
#### Models
To use Unique3D you will need to download the following models and place them at the models folder in the root directory:
```bash
wget -c https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter_sd15.safetensors -P models/
wget -c https://huggingface.co/h94/IP-Adapter/resolve/main/models/image_encoder/model.safetensors -P models/
wget -c https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P models/
wget -c https://huggingface.co/spaces/Wuvin/Unique3D/resolve/main/ckpt/controlnet-tile/diffusion_pytorch_model.safetensors -P models/
wget -c https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt -P models/
```
You can check more details at the Unique3D section of the [README.md](../README.md) file.
### Build Docker Image
You can build the docker image using the following command:
```bash
DOCKER_BUILDKIT=0 docker build -t comfy3d --file Dockerfile .
```
You can also build the image using the docker-compose file:
```bash
DOCKER_BUILDKIT=0 docker compose build
```
> OBS: The `DOCKER_BUILDKIT=0` is used to disable the buildkit feature, which is not supported by the docker-compose file.
### Run Docker Container
You can run the docker container using the following command:
```bash
docker run -d \
--name comfy3d \
--platform linux/amd64 \
--runtime=nvidia \
-p 8188:8188 \
-e NVIDIA_VISIBLE_DEVICES=all \
-e NVIDIA_DRIVER_CAPABILITIES=all \
-e COMFYUI_PATH=/app \
-v $(pwd)/output:/app/output \
-v $(pwd)/models/diffusion_pytorch_model.safetensors:/app/models/controlnet/control_unique3d_sd15_tile.safetensors \
-v $(pwd)/models/ip-adapter_sd15.safetensors:/app/models/ipadapter/ip-adapter_sd15.safetensors \
-v $(pwd)/models/RealESRGAN_x4plus.pth:/app/models/upscale_models/RealESRGAN_x4plus.pth \
-v $(pwd)/models/v1-5-pruned-emaonly.ckpt:/app/models/checkpoints/v1-5-pruned-emaonly.ckpt \
-v $(pwd)/models/model.safetensors:/app/models/clip_vision/OpenCLIP-ViT-H-14.safetensors \
comfy3d
```
You can also run the container using the docker-compose file:
```bash
docker compose up
```
### Access the Application
After running the container, you can access the application by opening the following URL in your browser:
```
http://localhost:8188
```
To test, you can load the following workflow:
- `./_Example_Workflows/Unique3D/Unique3D_All_Stages.json`
+54 -8
View File
@@ -1,6 +1,6 @@
ARG CUDA_VERSION=12.1.0-devel
FROM docker.io/nvidia/cuda:${CUDA_VERSION}-ubuntu22.04
FROM --platform=amd64 docker.io/nvidia/cuda:${CUDA_VERSION}-ubuntu22.04
RUN apt-get update && \
apt-get install --no-install-recommends -y \
@@ -27,14 +27,18 @@ RUN apt-get update && \
ninja-build \
python3.11 \
python3.11-dev \
python3.11-venv \
wget \
&& \
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11 && \
rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/bin/python3.11 /usr/bin/python & \
ln -s /usr/bin/python3.11 /usr/bin/python3 & \
ln -s /usr/bin/pip3.11 /usr/bin/pip
RUN python -m pip install --upgrade pip
RUN adduser --uid 1001 -q user && \
mkdir /app && chown user /app
USER user
@@ -53,35 +57,77 @@ ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,graphics
ENV PYOPENGL_PLATFORM egl
WORKDIR /app
# Clone ComfyUI repository
RUN git clone "https://github.com/comfyanonymous/ComfyUI.git" ./ && \
git reset --hard 05cd00695a84cebd5603a31f665eb7301fba2beb
git reset --hard 29c2e26724d4982a3e33114eb9064f1a11f4f4ed
# Setup a virtual environment
RUN python -m venv venv
# Activate the virtual environment
ENV PATH="/app/venv/bin:$PATH" \
VIRTUAL_ENV="/app/venv" \
PYTHONPATH="/app/venv/lib/python3.11/site-packages" \
PYTHONUSERBASE="/app/venv"
# Install the requirements
RUN pip install --no-cache -r requirements.txt
WORKDIR /app/custom_nodes/ComfyUI-3D-Pack/
COPY --chown=user:user requirements.txt ./
COPY --chown=user:user install.py ./
RUN pip install --no-cache -r requirements.txt \
# post requirements installation require gpu, setup
# `nvidia-container-runtime`, for docker, see
# https://stackoverflow.com/a/61737404
# those seem to be missed
ninja rembg[gpu] open_clip_torch \
python install.py
ninja rembg[gpu] open_clip_torch
COPY --chown=user:user ./ ./
RUN python install.py
# Install Custom Nodes
WORKDIR /app/custom_nodes/
# Essential nodes
RUN git clone "https://github.com/ltdrdata/ComfyUI-Impact-Pack" && \
cd ComfyUI-Impact-Pack && \
git reset --hard e1570e76799049fb0038f6232fd89800ab4565eb && \
git reset --hard ab17f8886945b0d36478950fe532164a8b569cc7 && \
pip install --no-cache -r requirements.txt
RUN git clone "https://github.com/kijai/ComfyUI-KJNodes" && \
cd ComfyUI-KJNodes && \
git reset --hard 95ae8b067a8aa5825471189954579ffa02aa9256 && \
git reset --hard ffafc9c2c675ce4e89386c725def331a88274004 && \
pip install --no-cache -r requirements.txt
RUN git clone "https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite" && \
cd ComfyUI-VideoHelperSuite && \
git reset --hard f94597739f20dac331f9918a245149b6b00a60f2 && \
git reset --hard 70faa9bcef65932ab72e7404d6373fb300013a2e && \
pip install --no-cache -r requirements.txt
COPY --chown=user:user ./ ComfyUI-3D-Pack/
# Extra nodes
RUN git clone "https://github.com/cubiq/ComfyUI_IPAdapter_plus" && \
cd ComfyUI_IPAdapter_plus && \
git reset --hard 13fedc634d1abf19d289fc7a7b5a74589465206c
RUN git clone "https://github.com/ssitu/ComfyUI_UltimateSDUpscale" --recursive && \
cd ComfyUI_UltimateSDUpscale && \
git reset --hard 70083f5d449c498ee0fb35f5293c91cebac4b758
RUN git clone "https://github.com/ltdrdata/ComfyUI-Inspire-Pack" && \
cd ComfyUI-Inspire-Pack && \
git reset --hard cadf604de528be62e4fbb1e3d12c51c98f20f50b && \
pip install --no-cache -r requirements.txt
RUN git clone "https://github.com/edenartlab/eden_comfy_pipelines" && \
cd eden_comfy_pipelines && \
git reset --hard 1b64dd507e8560466a8a50b8b8a704547890f525 && \
pip install --no-cache -r requirements.txt
RUN git clone "https://github.com/WASasquatch/was-node-suite-comfyui" && \
cd was-node-suite-comfyui && \
git reset --hard e036c1aa1b228c31473f78e020f47f0ce94d4c80 && \
pip install --no-cache -r requirements.txt
# Clone comfyui-manager to handle extra nodes
RUN git clone "https://github.com/ltdrdata/ComfyUI-Manager.git" && \
cd ComfyUI-Manager && \
git reset --hard 2b8e76197ae970dbd7854a09a5ef57731dc1c82f
WORKDIR /app
ENTRYPOINT [ "python", "main.py", "--listen", "0.0.0.0" ]
+3
View File
@@ -23,6 +23,7 @@ This is an extensive node suite that enables ComfyUI to process 3D inputs (Mesh
- [install.py](install.py) will download & install Pre-builds automatically according to your runtime environment, if it couldn't find corresponding Pre-builds, then [build script](_Pre_Builds/_Build_Scripts/auto_build_all.py) will start automatically, if automatic build doesn't work for you, then please check out [Semi-Automatic Build Guide](_Pre_Builds/README.md#build-required-packages-semi-automatically)
- If you have any missing node in any open Comfy3D workflow, try simply click [Install Missing Custom Nodes](https://github.com/ltdrdata/ComfyUI-Manager?tab=readme-ov-file#support-of-missing-nodes-installation) in ComfyUI-Manager
- If for some reason your comfy3d can't download pre-trained models automatically, you can always download them manually and put them in to correct folder under [Checkpoints](Checkpoints) directory, but please **DON'T** overwrite any exist .json files
- Docker install please check [DOCKER_INSTRUCTIONS.md](DOCKER_INSTRUCTIONS.md)
- **Note:** at this moment, you'll still need to install [Visual Studio Build Tools for windows](_Pre_Builds/README.md#build-for-windows) and [install `gcc g++` for Linux](_Pre_Builds/README.md#build-for-linux) in order for `InstantNGP & Convert 3DGS to Mesh with NeRF and Marching_Cubes` nodes to work, since those two nodes used JIT torch cpp extension that builds in runtime, but I plan to replace those nodes soon
## Features:
@@ -42,8 +43,10 @@ This is an extensive node suite that enables ComfyUI to process 3D inputs (Mesh
3. Multi-view images to Normal maps with resulution: 512X512, super resolution to 2048X2048
4. Multi-view images & Normal maps to 3D mesh with texture
- To use the [All stage Unique3D workflow](./_Example_Workflows/Unique3D/Unique3D_All_Stages.json), Download Models:
- [sdv1.5-pruned-emaonly](https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly.ckpt) and put it into `Your ComfyUI root directory/ComfyUI/models/checkpoints`
- [fine-tuned controlnet-tile](https://huggingface.co/spaces/Wuvin/Unique3D/tree/main/ckpt/controlnet-tile) and put it into `Your ComfyUI root directory/ComfyUI/models/controlnet`
- [ip-adapter_sd15](https://huggingface.co/h94/IP-Adapter/blob/main/models/ip-adapter_sd15.safetensors) and put it into `Your ComfyUI root directory/ComfyUI/models/ipadapter`
- [OpenCLIP-ViT-H-14](https://huggingface.co/h94/IP-Adapter/blob/main/models/image_encoder/model.safetensors), rename it to **OpenCLIP-ViT-H-14.safetensors** and put it into `Your ComfyUI root directory/ComfyUI/models/clip_vision`
- [RealESRGAN_x4plus](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth) and put it into `Your ComfyUI root directory/ComfyUI/models/upscale_models`
- Model weights: https://huggingface.co/spaces/Wuvin/Unique3D/tree/main/ckpt
@@ -781,7 +781,7 @@
"Node name for S&R": "CLIPVisionLoader"
},
"widgets_values": [
"CLIP-ViT-H-14-laion2B-s32B-b79K.safetensors"
"OpenCLIP-ViT-H-14.safetensors"
]
},
{
@@ -61,7 +61,7 @@
"Node name for S&R": "CLIPVisionLoader"
},
"widgets_values": [
"CLIP-ViT-H-14-laion2B-s32B-b79K.safetensors"
"OpenCLIP-ViT-H-14.safetensors"
]
},
{
@@ -14,7 +14,7 @@
26
],
"flags": {},
"order": 12,
"order": 18,
"mode": 0,
"inputs": [
{
@@ -50,7 +50,7 @@
"1": 121.17926025390625
},
"flags": {},
"order": 10,
"order": 16,
"mode": 0,
"inputs": [
{
@@ -197,7 +197,7 @@
"1": 123.00312042236328
},
"flags": {},
"order": 11,
"order": 17,
"mode": 0,
"inputs": [
{
@@ -352,7 +352,7 @@
26
],
"flags": {},
"order": 19,
"order": 25,
"mode": 0,
"inputs": [
{
@@ -377,57 +377,6 @@
"horizontal": false
}
},
{
"id": 238,
"type": "CheckpointLoaderSimple",
"pos": [
1642.6586640526511,
-1295.0556190475177
],
"size": {
"0": 354.010986328125,
"1": 98
},
"flags": {},
"order": 2,
"mode": 0,
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
523
],
"shape": 3,
"slot_index": 0
},
{
"name": "CLIP",
"type": "CLIP",
"links": [
524,
525
],
"shape": 3,
"slot_index": 1
},
{
"name": "VAE",
"type": "VAE",
"links": [
526
],
"shape": 3,
"slot_index": 2
}
],
"properties": {
"Node name for S&R": "CheckpointLoaderSimple"
},
"widgets_values": [
"sd15\\v1-5-pruned-emaonly.ckpt"
]
},
{
"id": 241,
"type": "IPAdapterAdvanced",
@@ -511,7 +460,7 @@
"1": 58
},
"flags": {},
"order": 3,
"order": 2,
"mode": 0,
"outputs": [
{
@@ -531,37 +480,6 @@
"ip-adapter_sd15.safetensors"
]
},
{
"id": 243,
"type": "CLIPVisionLoader",
"pos": [
3023,
-1126
],
"size": {
"0": 409.337158203125,
"1": 58
},
"flags": {},
"order": 4,
"mode": 0,
"outputs": [
{
"name": "CLIP_VISION",
"type": "CLIP_VISION",
"links": [
519
],
"shape": 3
}
],
"properties": {
"Node name for S&R": "CLIPVisionLoader"
},
"widgets_values": [
"CLIP-ViT-H-14-laion2B-s32B-b79K.safetensors"
]
},
{
"id": 192,
"type": "ControlNetLoader",
@@ -574,7 +492,7 @@
"1": 58
},
"flags": {},
"order": 5,
"order": 3,
"mode": 0,
"outputs": [
{
@@ -784,7 +702,7 @@
}
},
"widgets_values": [
"Unique3D\\Upscales\\rgb_highres"
"Unique3D/Upscales/rgb_highres"
],
"color": "#223",
"bgcolor": "#335"
@@ -1006,7 +924,7 @@
"Node name for S&R": "[Comfy3D] Save 3D Mesh"
},
"widgets_values": [
"Unique3D\\Mesh_Gen_0\\mesh.obj"
"Unique3D/Mesh_Gen_0/mesh.obj"
]
},
{
@@ -1045,7 +963,7 @@
"Node name for S&R": "[Comfy3D] Save 3D Mesh"
},
"widgets_values": [
"Unique3D\\Mesh_Gen_1\\mesh.obj"
"Unique3D/Mesh_Gen_1/mesh.obj"
]
},
{
@@ -1116,7 +1034,7 @@
"Node name for S&R": "[Comfy3D] Save 3D Mesh"
},
"widgets_values": [
"Unique3D\\Mesh_Gen_2\\mesh.obj"
"Unique3D/Mesh_Gen_2/mesh.obj"
]
},
{
@@ -1163,7 +1081,7 @@
"1": 58
},
"flags": {},
"order": 24,
"order": 23,
"mode": 0,
"inputs": [
{
@@ -1202,7 +1120,7 @@
"1": 58
},
"flags": {},
"order": 17,
"order": 14,
"mode": 0,
"inputs": [
{
@@ -1241,7 +1159,7 @@
"1": 126
},
"flags": {},
"order": 22,
"order": 21,
"mode": 0,
"inputs": [
{
@@ -1319,7 +1237,7 @@
"1": 58
},
"flags": {},
"order": 25,
"order": 24,
"mode": 0,
"inputs": [
{
@@ -1358,7 +1276,7 @@
"1": 58
},
"flags": {},
"order": 18,
"order": 15,
"mode": 0,
"inputs": [
{
@@ -1476,7 +1394,7 @@
],
"properties": {},
"widgets_values": [
"Unique3D\\RGB\\rgb"
"Unique3D/RGB/rgb"
]
},
{
@@ -1697,7 +1615,7 @@
"1": 26
},
"flags": {},
"order": 15,
"order": 12,
"mode": 0,
"inputs": [
{
@@ -2111,7 +2029,7 @@
"1": 130
},
"flags": {},
"order": 13,
"order": 10,
"mode": 0,
"inputs": [
{
@@ -2248,7 +2166,7 @@
"1": 26
},
"flags": {},
"order": 21,
"order": 20,
"mode": 0,
"inputs": [
{
@@ -2284,7 +2202,7 @@
"1": 130
},
"flags": {},
"order": 20,
"order": 19,
"mode": 0,
"inputs": [
{
@@ -2342,7 +2260,7 @@
"1": 314.0000305175781
},
"flags": {},
"order": 6,
"order": 4,
"mode": 0,
"outputs": [
{
@@ -2385,7 +2303,7 @@
26
],
"flags": {},
"order": 14,
"order": 11,
"mode": 0,
"inputs": [
{
@@ -2574,7 +2492,7 @@
"Node name for S&R": "[Comfy3D] Save 3D Mesh"
},
"widgets_values": [
"Unique3D\\Mesh_Gen_3\\mesh.obj"
"Unique3D/Mesh_Gen_3/mesh.obj"
]
},
{
@@ -2819,7 +2737,7 @@
26
],
"flags": {},
"order": 16,
"order": 13,
"mode": 0,
"inputs": [
{
@@ -2855,7 +2773,7 @@
26
],
"flags": {},
"order": 23,
"order": 22,
"mode": 0,
"inputs": [
{
@@ -3001,7 +2919,7 @@
"1": 58
},
"flags": {},
"order": 7,
"order": 5,
"mode": 0,
"outputs": [
{
@@ -3035,7 +2953,7 @@
"1": 154
},
"flags": {},
"order": 8,
"order": 6,
"mode": 0,
"outputs": [
{
@@ -3071,7 +2989,7 @@
"1": 154
},
"flags": {},
"order": 9,
"order": 7,
"mode": 0,
"outputs": [
{
@@ -3094,6 +3012,88 @@
false,
"image2normal"
]
},
{
"id": 243,
"type": "CLIPVisionLoader",
"pos": [
3023,
-1126
],
"size": {
"0": 409.337158203125,
"1": 58
},
"flags": {},
"order": 8,
"mode": 0,
"outputs": [
{
"name": "CLIP_VISION",
"type": "CLIP_VISION",
"links": [
519
],
"shape": 3
}
],
"properties": {
"Node name for S&R": "CLIPVisionLoader"
},
"widgets_values": [
"OpenCLIP-ViT-H-14.safetensors"
]
},
{
"id": 238,
"type": "CheckpointLoaderSimple",
"pos": [
1642.6586640526511,
-1295.0556190475177
],
"size": {
"0": 354.010986328125,
"1": 98
},
"flags": {},
"order": 9,
"mode": 0,
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
523
],
"shape": 3,
"slot_index": 0
},
{
"name": "CLIP",
"type": "CLIP",
"links": [
524,
525
],
"shape": 3,
"slot_index": 1
},
{
"name": "VAE",
"type": "VAE",
"links": [
526
],
"shape": 3,
"slot_index": 2
}
],
"properties": {
"Node name for S&R": "CheckpointLoaderSimple"
},
"widgets_values": [
"v1-5-pruned-emaonly.ckpt"
]
}
],
"links": [
@@ -3984,10 +3984,10 @@
"config": {},
"extra": {
"ds": {
"scale": 0.6727499949326112,
"scale": 0.6115909044841983,
"offset": [
-2947.1491377521043,
-1183.618622374594
-652.655172706287,
1878.426947493726
]
}
},
+21
View File
@@ -0,0 +1,21 @@
services:
comfy3d:
build:
context: .
dockerfile: Dockerfile
platform: linux/amd64
runtime: nvidia
image: comfy3d
ports:
- "8188:8188"
environment:
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=all
- COMFYUI_PATH=/app
volumes:
# - ./output:/app/output
- ./models/diffusion_pytorch_model.safetensors:/app/models/controlnet/control_unique3d_sd15_tile.safetensors
- ./models/ip-adapter_sd15.safetensors:/app/models/ipadapter/ip-adapter_sd15.safetensors
- ./models/RealESRGAN_x4plus.pth:/app/models/upscale_models/RealESRGAN_x4plus.pth
- ./models/v1-5-pruned-emaonly.ckpt:/app/models/checkpoints/v1-5-pruned-emaonly.ckpt
- ./models/model.safetensors:/app/models/clip_vision/OpenCLIP-ViT-H-14.safetensors