ALBANIA

ARGENTINA

AUSTRALIA

AUSTRIA

AZERBAIJAN

BANGLADESH

BELGIUM

BOSNIA AND HERZEGOVINA

BRAZIL

BULGARIA

CANADA

CHILE

CHINA

COLOMBIA

COSTA RICA

CROATIA

CYPRUS

CZECH REPUBLIC

DENMARK

ECUADOR

EGYPT

EL SALVADOR

ESTONIA

FINLAND

FRANCE

GEORGIA

GERMANY

GREECE

GUATEMALA

HUNGARY

ICELAND

INDIA

INDONESIA

IRELAND

ISRAEL

ITALY

JAPAN

KAZAKHSTAN

KENYA

KOSOVO

LATVIA

LIBYA

LITHUANIA

LUXEMBOURG

MALAYSIA

MALTA

MEXICO

MOLDOVA

MONTENEGRO

MOROCCO

NETHERLANDS

NEW ZEALAND

NIGERIA

NORWAY

PAKISTAN

PANAMA

PARAGUAY

PERU

PHILIPPINES

POLAND

PORTUGAL

QATAR

ROMANIA

RUSSIA

SAUDI ARABIA

SERBIA

SINGAPORE

SLOVAKIA

SLOVENIA

SOUTH AFRICA

SOUTH KOREA

SPAIN

SWEDEN

SWITZERLAND

TAIWAN

THAILAND

TUNISIA

TURKEY

UKRAINE

UNITED ARAB EMIRATES

UNITED KINGDOM

URUGUAY

USA

UZBEKISTAN

VIETNAM

Run ComfyUI and Stable Diffusion on a Dedicated GPU Server

A practical Ubuntu guide to installing ComfyUI, configuring NVIDIA GPU acceleration, loading Stable Diffusion models, and securely accessing your AI image-generation server.

ComfyUI gives you a node-based interface for building and running image-generation workflows. When it runs on a dedicated GPU server, you get access to powerful graphics hardware, persistent model storage, and a machine that can stay available for longer rendering sessions. This setup is useful for creators, developers, studios, and teams that need more control than a typical desktop installation.

This tutorial walks through a manual installation on an Ubuntu Linux server with an NVIDIA GPU. You will prepare the server, verify its GPU and driver, install ComfyUI and its PyTorch dependencies, add a Stable Diffusion checkpoint, generate a test image, and connect to the interface securely.

Scope: The commands below are for an Ubuntu server with an NVIDIA GPU and a working NVIDIA driver. AMD and Intel GPU installations use different PyTorch backends and are outside this walkthrough. Package versions and supported GPU architectures change, so use the current ComfyUI and PyTorch installation instructions if your hardware requires a different build.

What You Will Build

By the end, you will have:

  • ComfyUI installed in an isolated Python virtual environment.

  • PyTorch configured to use the NVIDIA GPU through CUDA.

  • A Stable Diffusion model stored in ComfyUI's checkpoints directory.

  • A working text-to-image workflow.

  • A safer way to access ComfyUI remotely without exposing its unauthenticated interface directly to the public internet.

1. Understand the Components

Before installing anything, it helps to understand how the parts work together.

  • Dedicated GPU server: A physical server with a GPU assigned to your workloads. Its GPU performs the computationally intensive parts of image generation.

  • NVIDIA driver: Allows Linux applications to communicate with the NVIDIA GPU.

  • CUDA-enabled PyTorch: The machine-learning framework ComfyUI uses to execute supported operations on the GPU.

  • ComfyUI: A node-based interface and execution engine. Nodes represent operations such as loading a model, encoding a prompt, sampling latent data, decoding an image, and saving the result.

  • Stable Diffusion checkpoint: The model weights used to generate images. Different model families and checkpoints have different hardware, quality, and workflow requirements.

ComfyUI is not itself a Stable Diffusion model. It loads a compatible model and runs a workflow that describes how the model should be used.

2. Check Dedicated GPU Server Requirements

Image generation depends heavily on GPU memory (VRAM), system RAM, storage, and the model you choose. A dedicated GPU server is particularly useful when you need sustained workloads, multiple workflows, or a persistent library of large model files.

Suggested starting configuration

The following is a planning guide, not a guarantee that every model or workflow will run at these specifications.

Component Practical starting point Why it matters
GPU NVIDIA GPU with CUDA support; choose VRAM according to the model and workflow VRAM affects which models, resolutions, and batch sizes can fit
System RAM 16 GB or more; 32 GB or more is a more comfortable target for larger workflows Supports Linux, Python, model loading, and CPU offloading
Storage SSD or NVMe storage, with capacity reserved for models and outputs Checkpoints, VAE files, LoRAs, ControlNet models, and generated images can consume substantial space
CPU Modern multi-core processor Helps with preprocessing, data handling, and general server tasks
Network Reliable connectivity and sufficient transfer capacity Model downloads and remote workflow access depend on the network
Operating system Supported 64-bit Ubuntu LTS release Provides a familiar environment for NVIDIA drivers and Python tooling

A model's VRAM requirement varies with its architecture, precision, resolution, batch size, and workflow. A GPU with more VRAM gives you more room to work, but it does not automatically make every workflow faster. Check the model publisher's requirements before selecting a server.

Check your GPU before proceeding

Connect to the server using SSH:

ssh username@SERVER_IP

Check the operating system:

lsb_release -a

Check whether the NVIDIA driver can see the GPU:

nvidia-smi

The output should show your GPU model, driver version, GPU memory, and current utilization.

If nvidia-smi is missing or cannot communicate with the driver, resolve the server's NVIDIA driver installation before installing PyTorch. Use the driver package recommended for your GPU and Ubuntu release by your server provider or NVIDIA's official documentation. Do not assume that installing the CUDA toolkit alone will install or repair the NVIDIA kernel driver.

3. Prepare Ubuntu and Python

Update the package index and install the basic tools:

sudo apt update
sudo apt upgrade -y
sudo apt install -y git python3 python3-venv python3-pip python3-dev \
  build-essential libgl1 libglib2.0-0

Check the Python version:

python3 --version

Use a Python version supported by the current ComfyUI release and any custom nodes you intend to install. Python 3.12 or 3.13 is a sensible starting point for many current setups, but confirm compatibility before creating a production environment.

Create a directory for the application:

mkdir -p ~/ai
cd ~/ai

Keeping ComfyUI in its own directory makes it easier to manage model files, workflows, logs, and backups.

4. Download and Install ComfyUI

Clone the official ComfyUI repository:

git clone https://github.com/Comfy-Org/ComfyUI.git
cd ComfyUI

Create and activate a Python virtual environment:

python3 -m venv .venv
source .venv/bin/activate

Upgrade the Python packaging tools:

python -m pip install --upgrade pip setuptools wheel

A virtual environment keeps ComfyUI's Python packages separate from the operating system's Python installation. This reduces dependency conflicts and makes future maintenance easier.

Install a CUDA-enabled PyTorch build

ComfyUI needs a PyTorch build that supports your GPU. The correct installation command depends on your GPU generation, driver, operating system, and the CUDA wheel supported by the current PyTorch release.

For supported recent NVIDIA GPUs, the current ComfyUI installation guidance provides this example command:

pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu130

Important: Treat this as an example for compatible systems, not a universal command. Before running it, check the current ComfyUI installation instructions and the official PyTorch selector. If your GPU or driver requires another CUDA wheel, select the matching supported build there. Avoid mixing packages from different CUDA builds in the same virtual environment.

Official installation references:

  • ComfyUI: https://github.com/Comfy-Org/ComfyUI

  • PyTorch installation selector: https://pytorch.org/get-started/locally/

Install ComfyUI's remaining Python dependencies:

pip install -r requirements.txt

Confirm that PyTorch detects the GPU

Run:

python -c "import torch; print('PyTorch:', torch.__version__); print('CUDA available:', torch.cuda.is_available()); print('GPU:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'Not detected')"

A successful GPU setup should report CUDA available: True and display the NVIDIA GPU name.

If it reports False, do not continue on the assumption that image generation will use the GPU. Check the NVIDIA driver with nvidia-smi, confirm that you installed a CUDA-enabled PyTorch wheel, and verify that the wheel supports your GPU and driver combination.

5. Download a Stable Diffusion Model

ComfyUI needs model weights before it can generate an image. A checkpoint is commonly distributed as a .safetensors file, although some model families use multiple files or a different directory structure.

Choose a model that is compatible with your intended workflow and available GPU memory. Read the model publisher's documentation and license before downloading or using it, especially for commercial projects.

For a standard single-checkpoint workflow, place the checkpoint in:

~/ai/ComfyUI/models/checkpoints/

Create the directory if it does not already exist:

mkdir -p models/checkpoints

Download the model from its official publisher or a trusted model repository. For example, if the publisher provides a direct download URL, you can use:

wget -O models/checkpoints/your-model.safetensors "MODEL_DOWNLOAD_URL"

Replace MODEL_DOWNLOAD_URL with the real URL supplied by the publisher. Do not use an unverified file-sharing link or assume that every Stable Diffusion model is a single checkpoint.

Other model files

Depending on the workflow, you may also need:

Model asset Common ComfyUI directory
Checkpoints models/checkpoints/
VAE files models/vae/
LoRA files models/loras/
ControlNet models models/controlnet/
Embeddings models/embeddings/
Upscale models models/upscale_models/
Diffusion models models/diffusion_models/
Text encoders models/text_encoders/

Not every workflow uses every directory. Follow the model and workflow instructions, because newer architectures may require separate diffusion models, text encoders, and other components rather than one traditional checkpoint.

6. Start ComfyUI on the Dedicated GPU Server

From the ComfyUI directory, with the virtual environment activated, start the application:

python main.py

ComfyUI normally listens on port 8188. When running with its default local binding, it is intended to be accessed from the server itself.

To check that the process is listening:

ss -ltnp | grep 8188

Keep the terminal session open while testing. The startup output can help you identify missing dependencies, model-loading problems, or GPU errors.

Access ComfyUI securely from your computer

For an initial remote setup, use an SSH tunnel rather than exposing port 8188 publicly.

On your local computer, open a new terminal and run:

ssh -L 8188:127.0.0.1:8188 username@SERVER_IP

Keep the SSH connection open. Then open this address in your local browser:

http://127.0.0.1:8188

The browser connects through the encrypted SSH tunnel to ComfyUI on the server. This approach is useful for an administrator or an individual user who needs private access.

Security warning: Do not expose ComfyUI's unauthenticated web interface directly to the public internet. If several users need browser access, place it behind a properly configured HTTPS reverse proxy with authentication, restrict network access with a firewall or VPN, and keep the application and custom nodes updated. A reverse proxy by itself does not automatically provide authentication.

7. Generate Your First Stable Diffusion Image

Once the ComfyUI interface opens, load a workflow that matches the model you installed.

A typical text-to-image workflow contains these stages:

  • 1. Load Checkpoint: Select the compatible Stable Diffusion checkpoint.

  • 2. CLIP Text Encode (Prompt): Enter the positive prompt describing the image.

  • 3. CLIP Text Encode (Negative): Optionally describe elements you want the model to avoid, if supported by that model and workflow.

  • 4. Empty Latent Image: Set the initial width, height, and batch size.

  • 5. KSampler: Configure sampling steps, guidance, sampler, scheduler, and seed.

  • 6. VAE Decode: Convert the generated latent representation into an image.

  • 7. Save Image: Write the output to ComfyUI's output directory.

The exact nodes and settings depend on the model family. Use a workflow published for your specific model rather than assuming that a workflow designed for one Stable Diffusion generation will work unchanged with another.

Example prompt

A modern glass-and-steel research laboratory at sunrise,
cinematic architectural photography, realistic materials,
soft natural lighting, detailed environment

For your first test, use a moderate image resolution and a batch size of one. This makes it easier to identify configuration or VRAM issues before increasing the workload.

Select the checkpoint in the model loader, enter your prompt, and click Queue Prompt. ComfyUI will execute the workflow and save the generated image.

8. Monitor GPU Usage and Server Resources

A dedicated GPU server should be monitored during image generation. This helps you understand whether a workload is limited by GPU memory, GPU utilization, system RAM, CPU, or storage.

In a separate SSH session, run:

watch -n 1 nvidia-smi

This refreshes the GPU status every second. Observe:

  • GPU utilization: Indicates how busy the GPU is.

  • Memory usage: Shows how much VRAM is occupied.

  • Power and temperature: Help identify thermal or power constraints.

  • Running processes: Helps identify which process is using the GPU.

You can also monitor system memory and disk capacity:

free -h
df -h

If a workflow runs out of VRAM, try reducing the image resolution or batch size, using a lower-memory model variant where appropriate, or enabling a supported memory-saving option. Model offloading can help some workflows fit, but it may increase generation time because data has to move between system RAM and GPU memory.

9. Improve Performance and Manage Models

A dedicated GPU server gives you control over the environment, but good performance still depends on model selection and workflow design.

Use a model that fits the workload

Choose the model architecture, precision, and checkpoint size based on the image quality and speed you need. A smaller or quantized model may reduce memory use, while a larger model may require more VRAM and storage.

Use appropriate image dimensions

Higher resolutions and larger batches generally increase memory requirements. Start with a modest resolution, confirm that the workflow completes, and increase dimensions gradually while monitoring VRAM.

Keep model storage organized

Separate checkpoints, LoRAs, VAEs, ControlNet files, and outputs into their expected directories. Use clear filenames and keep a record of each model's source, version, and license.

Reuse workflows

Save working workflows as JSON files. This makes it easier to reproduce image-generation settings, share a workflow with teammates, and troubleshoot changes. A workflow file does not necessarily include the model weights or custom nodes it depends on, so document those dependencies separately.

Add custom nodes carefully

Custom nodes extend ComfyUI with additional operations and integrations. Install them only from sources you trust, check their compatibility with your ComfyUI and Python versions, and review their dependencies. Back up a working environment before adding or updating multiple extensions.

10. Common ComfyUI and Stable Diffusion Problems

ComfyUI says CUDA is not available

Possible causes: CPU-only PyTorch was installed, the CUDA wheel is incompatible, or the NVIDIA driver is not working.

What to check:

nvidia-smi

Then check PyTorch:

python -c "import torch; print(torch.cuda.is_available()); print(torch.version.cuda)"

Reinstall a compatible PyTorch build using the official PyTorch selector and the current ComfyUI instructions. Run the commands inside the activated ComfyUI virtual environment.

CUDA out of memory

Possible causes: The model, image dimensions, batch size, or workflow exceeds available VRAM.

What to try:

  • Reduce image width and height.

  • Reduce batch size to one.

  • Close other GPU workloads.

  • Use a compatible lower-memory model or precision.

  • Enable a memory-saving option supported by your ComfyUI version and workflow.

A checkpoint does not appear in ComfyUI

Possible causes: The file is in the wrong directory, the filename or download is incomplete, or the model is not a standard checkpoint.

What to try:

  • Confirm that the file is in models/checkpoints/ if it is a standard checkpoint.

  • Check that the download completed and the file is readable.

  • Confirm the model's required directory structure.

  • Refresh the model list or restart ComfyUI.

Missing nodes when opening a workflow

Possible causes: The workflow depends on custom nodes that are not installed.

What to try: Identify the missing node packages from the workflow, review their source and compatibility, then install the required packages according to their documentation. Restart ComfyUI after installation. Do not install unknown node packages simply because a workflow requests them.

The web interface is not reachable remotely

Possible causes: The SSH tunnel is not running, the wrong port is being forwarded, or ComfyUI is listening on a different interface or port.

What to check:

  • Confirm ComfyUI is running.

  • Confirm that it is listening on port 8188.

  • Keep the SSH tunnel open.

  • Open http://127.0.0.1:8188 on the same computer where you created the tunnel.

  • Check server and local firewall rules if the connection still fails.

Image generation is slower than expected

Possible causes: The workflow is using CPU execution, the GPU is underpowered for the model, VRAM pressure is causing offloading, or the workload includes expensive nodes.

What to check: Confirm CUDA availability, watch GPU utilization and memory during a run, and test a simple workflow with a moderate resolution. Compare results using the same model and settings before changing multiple variables.

11. Keep Your AI Image-Generation Server Secure and Maintainable

A ComfyUI server may contain proprietary workflows, model files, generated images, and access to a powerful compute resource. Treat it like any other production server.

  • Keep Ubuntu, NVIDIA drivers, ComfyUI, PyTorch, and custom nodes updated in a controlled maintenance process.

  • Use SSH keys where possible and disable password-based SSH access when your server administration policy permits.

  • Restrict inbound ports with a firewall. Keep port 8188 private unless you have a deliberate, protected remote-access design.

  • Use HTTPS and authentication when providing browser access through a reverse proxy.

  • Give users separate accounts or isolated environments where appropriate; do not share administrator credentials.

  • Back up workflow JSON files, configuration, and important generated assets.

  • Keep a record of model sources and licenses.

  • Monitor disk space and remove only files you no longer need.

  • Test updates in a separate environment before changing a working production setup.

For a shared service, consider separating users' workflows and output directories, applying resource limits, and monitoring job queues. ComfyUI's default interface should not be treated as a complete multi-user access-control system.

12. Why Use a Dedicated GPU Server for ComfyUI?

Running ComfyUI on a dedicated GPU server can be useful when local hardware is limited or when image generation is part of a repeatable business or development workflow.

A dedicated server can provide:

  • Dedicated compute resources: The assigned GPU is available for your workloads rather than shared with unrelated desktop applications.

  • More GPU memory options: You can choose hardware based on the models and image sizes you plan to run.

  • Persistent model storage: Keep checkpoints, LoRAs, workflows, and output files on server storage.

  • Remote access: Manage the environment from your workstation through SSH or a protected web-access setup.

  • Workflow flexibility: Run custom ComfyUI graphs and compatible Stable Diffusion models.

  • Room to scale: Upgrade GPU, RAM, or storage as the workload grows, subject to server availability and platform compatibility.

The right server depends on your model, expected image volume, concurrency, and budget. Estimate VRAM and storage requirements before choosing a configuration rather than selecting a GPU based on its name alone.

Conclusion

Running ComfyUI and Stable Diffusion on a dedicated GPU server gives you a flexible environment for AI image generation, custom workflows, and persistent model storage. The key is to match the GPU to the model, install a compatible CUDA-enabled PyTorch build, organize model files correctly, and protect remote access.

Start with a simple text-to-image workflow, verify GPU usage, and increase resolution or workflow complexity only after the setup is stable. With regular updates, sensible backups, and secure access controls, a dedicated GPU server can provide a dependable foundation for ongoing AI image-generation workloads.

Frequently Asked Questions

Can I run ComfyUI on a dedicated GPU server?

Yes. ComfyUI can run on a Linux dedicated GPU server when the operating system, GPU driver, Python environment, PyTorch build, and model files are configured correctly. An NVIDIA GPU with a compatible CUDA-enabled PyTorch installation is a common setup.

Do I need an NVIDIA GPU to run ComfyUI?

No. ComfyUI supports multiple hardware platforms, but the installation process differs between NVIDIA, AMD, Intel, and other supported backends. This tutorial covers NVIDIA GPUs on Ubuntu.

Is ComfyUI the same as Stable Diffusion?

No. Stable Diffusion is a family of image-generation models. ComfyUI is a node-based interface and execution engine that can load compatible models and run image-generation workflows.

How much VRAM do I need for Stable Diffusion?

There is no single VRAM requirement for every Stable Diffusion model. Memory use depends on the model architecture, precision, image resolution, batch size, and workflow. Check the model's documentation and start with a workload that fits the GPU you plan to use.

Where do I put Stable Diffusion checkpoint files in ComfyUI?

For a standard checkpoint workflow, place checkpoint files in ComfyUI/models/checkpoints/. Other model architectures may require separate files in directories such as models/diffusion_models/ and models/text_encoders/. Always follow the model publisher's instructions.

Can I access ComfyUI from my local computer?

Yes. For private administration, an SSH tunnel is a straightforward option. It lets you open the server's ComfyUI interface in your local browser without making the application port publicly accessible.

Can multiple users use one ComfyUI server?

A single server can run workloads for multiple users, but you should design access control, job scheduling, storage separation, and resource limits carefully. Do not expose the default interface publicly as though it were a fully secured multi-user platform.

Can I use custom models and LoRAs?

Yes, if they are compatible with the workflow and ComfyUI version. Store each asset in its expected model directory and check its publisher's usage terms and license.

Does a dedicated GPU server make image generation faster?

It can provide more capable and consistently available GPU resources than a low-powered local machine. Actual generation speed depends on the GPU, model, precision, workflow, resolution, and software configuration.