2025/11/29

ComfyUI Stable Diffusion Service Setup

   This guide assumes you have Python 3.8+ and NVIDIA GPU drivers (CUDA 13.0 or compatible) installed on your system.


   1. Navigate to your desired project directory:

      Open your terminal and change to the directory where you want to install ComfyUI. If the directory doesn't exist, create it.


   1     cd /path/to/your/comfyui_project

   2     # If the directory is empty or you want a fresh start, ensure it is empty

   3     # If .venv exists, remove it: rm -rf .venv


   2. Clone the ComfyUI repository:

      This will download all the necessary ComfyUI files into your current directory.

   1     git clone https://github.com/comfyanonymous/ComfyUI.git .


   3. Create a Python Virtual Environment:

      We'll use uv to create an isolated environment for ComfyUI's dependencies.

   1     uv venv


   4. Install PyTorch with CUDA Support:

      This step is crucial for GPU acceleration. We'll use the specific PyTorch build that is compatible with your DGX Spark's CUDA environment (cu129 index).


   1     uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu129


   5. Install ComfyUI's remaining dependencies:

   1     uv pip install -r requirements.txt


   6. Download the Stable Diffusion Model:

      You need a Stable Diffusion model checkpoint. We'll download the v1-5-pruned-emaonly.safetensors model, which is a standard choice.

      First, ensure the target directory exists:


   1     mkdir -p models/checkpoints

      Then, download the model:


   1     wget -O models/checkpoints/v1-5-pruned-emaonly.safetensors https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors


   7. Launch the ComfyUI Server:

      To make ComfyUI accessible over your network (for tools like Open-WebUI), launch it with the --listen flag. You can run it in the foreground to see output or in the background:


       * To run in foreground (for debugging/monitoring):

   1         .venv/bin/python main.py --listen

          (You'll need to press Ctrl+C to stop it.)


       * To run in background (recommended for service):

   1         nohup .venv/bin/python main.py --listen > comfyui.log 2>&1 &

          This command runs ComfyUI in the background, redirects its output to comfyui.log, and detaches it from your terminal. You can check tail -f comfyui.log for logs or use fg to

  bring it back to foreground if launched using &.


   8. Verify ComfyUI is Running:

      Open your web browser and go to http://<YOUR_SPARK_IP>:8188. Replace <YOUR_SPARK_IP> with the actual IP address of your machine. If you see the ComfyUI interface, the server is

  running.


   9. Test Image Generation:

      Inside the ComfyUI web UI, try to generate a simple image using the default workflow. If it successfully generates an image, your Stable Diffusion service is fully operational.


   10. Connect to Open-WebUI:

      You can now configure Open-WebUI to use this ComfyUI instance by pointing its "API URL" setting to http://<YOUR_SPARK_IP>:8188.


沒有留言:

張貼留言