diff --git a/README.md b/README.md index f13b1f8..fe32710 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ [![Watch the video](https://i3.ytimg.com/vi/JovhfHhxqdM/hqdefault.jpg)](https://www.youtube.com/watch?v=JovhfHhxqdM) -Run the latest ComfyUI. First start installs dependencies (takes a few minutes), then when you see this in the logs, ComfyUI is ready to be used: `[ComfyUI-Manager] All startup tasks have been completed.` +Run the latest ComfyUI. First start installs dependencies (takes a few minutes), then when you see this in the logs, ComfyUI is ready to be used: `[ComfyUI-Manager] All startup tasks have been completed.` If multiple GPUs are assigned to a pod, it will create an instance of ComfyUI per each GPU. ## Access -- `8188`: ComfyUI web UI +- `8188`: ComfyUI web UI (for a singular GPU) +- `8188+n`: ComfyUI web UI (for multiple GPUs, starts with `8188` for the first GPU, increments upwards per each GPU) - `8080`: FileBrowser (admin / adminadmin12) - `8888`: JupyterLab (token via `JUPYTER_PASSWORD`, root at `/workspace`) - `22`: SSH (set `PUBLIC_KEY` or check logs for generated root password) @@ -29,3 +30,4 @@ Edit `/workspace/runpod-slim/comfyui_args.txt` (one arg per line): - `/workspace/runpod-slim/ComfyUI`: ComfyUI install - `/workspace/runpod-slim/comfyui_args.txt`: ComfyUI args - `/workspace/runpod-slim/filebrowser.db`: FileBrowser DB + diff --git a/README_5090.md b/README_5090.md index f13b1f8..fe32710 100644 --- a/README_5090.md +++ b/README_5090.md @@ -1,10 +1,11 @@ [![Watch the video](https://i3.ytimg.com/vi/JovhfHhxqdM/hqdefault.jpg)](https://www.youtube.com/watch?v=JovhfHhxqdM) -Run the latest ComfyUI. First start installs dependencies (takes a few minutes), then when you see this in the logs, ComfyUI is ready to be used: `[ComfyUI-Manager] All startup tasks have been completed.` +Run the latest ComfyUI. First start installs dependencies (takes a few minutes), then when you see this in the logs, ComfyUI is ready to be used: `[ComfyUI-Manager] All startup tasks have been completed.` If multiple GPUs are assigned to a pod, it will create an instance of ComfyUI per each GPU. ## Access -- `8188`: ComfyUI web UI +- `8188`: ComfyUI web UI (for a singular GPU) +- `8188+n`: ComfyUI web UI (for multiple GPUs, starts with `8188` for the first GPU, increments upwards per each GPU) - `8080`: FileBrowser (admin / adminadmin12) - `8888`: JupyterLab (token via `JUPYTER_PASSWORD`, root at `/workspace`) - `22`: SSH (set `PUBLIC_KEY` or check logs for generated root password) @@ -29,3 +30,4 @@ Edit `/workspace/runpod-slim/comfyui_args.txt` (one arg per line): - `/workspace/runpod-slim/ComfyUI`: ComfyUI install - `/workspace/runpod-slim/comfyui_args.txt`: ComfyUI args - `/workspace/runpod-slim/filebrowser.db`: FileBrowser DB + diff --git a/start.5090.sh b/start.5090.sh index d4ab31e..c5011cc 100644 --- a/start.5090.sh +++ b/start.5090.sh @@ -249,24 +249,39 @@ else done fi -# Start ComfyUI with custom arguments if provided +# Start ComfyUI instances per detected GPU with custom arguments if provided cd $COMFYUI_DIR -FIXED_ARGS="--listen 0.0.0.0 --port 8188" +FIXED_ARGS="--listen 0.0.0.0" +CUSTOM_ARGS="" if [ -s "$ARGS_FILE" ]; then # File exists and is not empty, combine fixed args with custom args CUSTOM_ARGS=$(grep -v '^#' "$ARGS_FILE" | tr '\n' ' ') if [ ! -z "$CUSTOM_ARGS" ]; then - echo "Starting ComfyUI with additional arguments: $CUSTOM_ARGS" - nohup python main.py $FIXED_ARGS $CUSTOM_ARGS &> /workspace/runpod-slim/comfyui.log & - else - echo "Starting ComfyUI with default arguments" - nohup python main.py $FIXED_ARGS &> /workspace/runpod-slim/comfyui.log & + echo "Additional ComfyUI arguments: $CUSTOM_ARGS" fi -else - # File is empty, use only fixed args - echo "Starting ComfyUI with default arguments" - nohup python main.py $FIXED_ARGS &> /workspace/runpod-slim/comfyui.log & fi -# Tail the log file -tail -f /workspace/runpod-slim/comfyui.log +# Determine GPU count (default to 1 if detection fails) +GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l) +if [ -z "$GPU_COUNT" ] || [ "$GPU_COUNT" -le 0 ]; then + GPU_COUNT=1 +fi + +echo "Detected $GPU_COUNT GPU(s); starting one ComfyUI instance per GPU" + +LOG_FILES=() +for (( gpu=0; gpu "$log_file" & + else + nohup python main.py $FIXED_ARGS --port "$port" --cuda-device "$gpu" &> "$log_file" & + fi +done + +# Tail log files from all instances +tail -f "${LOG_FILES[@]}" diff --git a/start.sh b/start.sh index 1611463..f6c1999 100644 --- a/start.sh +++ b/start.sh @@ -249,24 +249,39 @@ else done fi -# Start ComfyUI with custom arguments if provided +# Start ComfyUI instances per detected GPU with custom arguments if provided cd $COMFYUI_DIR -FIXED_ARGS="--listen 0.0.0.0 --port 8188" +FIXED_ARGS="--listen 0.0.0.0" +CUSTOM_ARGS="" if [ -s "$ARGS_FILE" ]; then # File exists and is not empty, combine fixed args with custom args CUSTOM_ARGS=$(grep -v '^#' "$ARGS_FILE" | tr '\n' ' ') if [ ! -z "$CUSTOM_ARGS" ]; then - echo "Starting ComfyUI with additional arguments: $CUSTOM_ARGS" - nohup python main.py $FIXED_ARGS $CUSTOM_ARGS &> /workspace/runpod-slim/comfyui.log & - else - echo "Starting ComfyUI with default arguments" - nohup python main.py $FIXED_ARGS &> /workspace/runpod-slim/comfyui.log & + echo "Additional ComfyUI arguments: $CUSTOM_ARGS" fi -else - # File is empty, use only fixed args - echo "Starting ComfyUI with default arguments" - nohup python main.py $FIXED_ARGS &> /workspace/runpod-slim/comfyui.log & fi -# Tail the log file -tail -f /workspace/runpod-slim/comfyui.log +# Determine GPU count (default to 1 if detection fails) +GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l) +if [ -z "$GPU_COUNT" ] || [ "$GPU_COUNT" -le 0 ]; then + GPU_COUNT=1 +fi + +echo "Detected $GPU_COUNT GPU(s); starting one ComfyUI instance per GPU" + +LOG_FILES=() +for (( gpu=0; gpu "$log_file" & + else + nohup python main.py $FIXED_ARGS --port "$port" --cuda-device "$gpu" &> "$log_file" & + fi +done + +# Tail log files from all instances +tail -f "${LOG_FILES[@]}"