A practical Ubuntu guide to installing ComfyUI, configuring NVIDIA GPU acceleration, loading Stable Diffusion models, and securely accessing your AI image-generation server.
ComfyUI provides a node-based interface for building and running AI image-generation workflows. When deployed on a dedicated GPU server, it gives creators and developers access to dedicated graphics resources, persistent model storage, and an environment for running longer image-generation sessions.
In this tutorial, we'll install ComfyUI on an Ubuntu server with an NVIDIA GPU, configure CUDA-enabled PyTorch, download a Stable Diffusion checkpoint, generate a test image, and configure secure remote access.
What we'll cover:
- Checking GPU and server requirements
- Preparing Ubuntu and Python
- Installing ComfyUI and PyTorch
- Configuring NVIDIA GPU acceleration
- Downloading Stable Diffusion models
- Running a text-to-image workflow
- Monitoring GPU performance
- Troubleshooting common installation issues
- Securing remote access to ComfyUI
Scope: This walkthrough covers Ubuntu Linux servers with NVIDIA GPUs and a working NVIDIA driver. AMD and Intel GPU installations require different software backends and are outside this guide.
Package versions and GPU compatibility change over time. Always check the current ComfyUI and PyTorch installation instructions before deploying a production environment.
1. Understand the Components
Before installing ComfyUI, let's understand the components involved.
Dedicated GPU server: A physical server with a GPU assigned to your workloads. The GPU handles the computationally intensive operations involved in 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 models, encoding prompts, sampling latent data, decoding images, and saving outputs.
Stable Diffusion checkpoint: The model weights used for image generation. Different model families have different hardware, memory, and workflow requirements.
One important distinction: ComfyUI is not itself a Stable Diffusion model. It loads compatible models and executes workflows that describe how those models should be used.
2. Check Dedicated GPU Server Requirements
AI image generation depends heavily on GPU memory (VRAM), system RAM, storage, and the model you select.
A dedicated GPU server is useful when you need sustained workloads, larger model libraries, or a persistent environment for image generation.
Suggested starting configuration
These are planning guidelines rather than guaranteed minimum requirements.
| Component | Suggested starting point |
|---|---|
| GPU | NVIDIA GPU with CUDA support; select VRAM according to your model and workflow |
| System RAM | 16 GB or more; 32 GB or more is a comfortable target for larger workflows |
| Storage | SSD or NVMe with enough space for models and generated images |
| CPU | Modern multi-core processor |
| Network | Reliable connection for model downloads and remote access |
| Operating system | Supported 64-bit Ubuntu LTS release |
GPU memory requirements vary according to model architecture, precision, image resolution, batch size, and workflow complexity.
A GPU with more VRAM gives you more flexibility, but it does not automatically make every workflow faster. Check the model publisher's requirements before choosing your server.
Connect to your server
Connect through SSH:
ssh username@SERVER_IP Check the Ubuntu version:
lsb_release -a Check whether the NVIDIA driver can detect your GPU:
nvidia-smi The output should show your GPU model, driver version, memory, and current utilization.
If nvidia-smi is missing or cannot communicate with the GPU, resolve the NVIDIA driver installation before continuing.
Use the driver package recommended for your GPU and Ubuntu release by your server provider or NVIDIA's official documentation.
Installing the CUDA toolkit alone does not install or repair the NVIDIA kernel driver.
3. Prepare Ubuntu and Python
Start by updating the package index and installing the required 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 your Python version:
python3 --version Use a Python version supported by your current ComfyUI release and the custom nodes you intend to install.
Python 3.12 or 3.13 can be suitable starting points for many current setups, but confirm compatibility before creating your environment.
Create a directory for AI applications:
mkdir -p ~/ai cd ~/ai Keeping your AI applications in a separate 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 a Python virtual environment:
python3 -m venv .venv source .venv/bin/activate Upgrade Python packaging tools:
python -m pip install --upgrade pip setuptools wheel A virtual environment keeps ComfyUI dependencies separate from the operating system's Python packages. This helps reduce dependency conflicts and makes maintenance easier.
Install CUDA-enabled PyTorch
ComfyUI needs a PyTorch build that supports your NVIDIA GPU.
The correct installation command depends on your GPU generation, driver, operating system, and the CUDA wheel supported by the current PyTorch release.
For compatible recent NVIDIA systems, the following is an example installation command:
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu130 Important: This is an example, not a universal command. Before installing it, check the current ComfyUI installation instructions and the official PyTorch selector. If your GPU or driver requires another CUDA build, choose the appropriate supported version.
Avoid mixing packages from different CUDA builds in the same virtual environment.
Official references:
- ComfyUI: https://github.com/Comfy-Org/ComfyUI
- PyTorch installation selector: https://pytorch.org/get-started/locally/
Install the remaining ComfyUI dependencies:
pip install -r requirements.txt Verify GPU detection
Run this command inside the activated virtual environment:
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 setup should report:
- CUDA available:
True - Your NVIDIA GPU name
If CUDA is unavailable, check the NVIDIA driver, PyTorch installation, GPU compatibility, and driver requirements before continuing.
5. Download a Stable Diffusion Model
ComfyUI needs compatible model weights before it can generate images.
A standard checkpoint is commonly distributed as a .safetensors file, although newer model families may require multiple components or a different directory structure.
Choose a model that matches your workflow and available GPU memory. Check the publisher's documentation and license, especially if you plan to use generated content commercially.
For a standard checkpoint workflow, use:
~/ai/ComfyUI/models/checkpoints/ Create the directory if it doesn't exist:
mkdir -p models/checkpoints Download the model from its official publisher or a trusted model repository.
For example:
wget -O models/checkpoints/your-model.safetensors "MODEL_DOWNLOAD_URL" Replace MODEL_DOWNLOAD_URL with the actual download URL provided by the model publisher.
Do not assume every model is a single checkpoint file.
Other model directories
Depending on your workflow, you may also need:
| Model asset | 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 all these directories. Newer architectures may require separate diffusion models, text encoders, and other components instead of one traditional checkpoint.
Follow the model publisher's instructions for the correct file structure.
6. Start ComfyUI on Your GPU Server
From the ComfyUI directory, with the virtual environment activated, run:
python main.py ComfyUI normally listens on port 8188.
To check whether the application is listening:
ss -ltnp | grep 8188 Keep the terminal session open while testing. The startup output can help identify missing dependencies, model-loading errors, and GPU issues.
Access ComfyUI securely from your computer
For private remote administration, an SSH tunnel is a straightforward option.
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 the following address in your local browser:
http://127.0.0.1:8188 Your browser connects through the encrypted SSH tunnel to the ComfyUI service on the remote server.
Security warning: Do not expose ComfyUI's unauthenticated web interface directly to the public internet.
If several users need browser access, use a properly configured HTTPS reverse proxy with authentication, restrict network access through a firewall or VPN, and keep ComfyUI and custom nodes updated.
A reverse proxy alone does not automatically provide authentication.
7. Generate Your First Stable Diffusion Image
Once the ComfyUI interface opens, load a workflow compatible with your installed model.
A typical text-to-image workflow contains these stages:
- Load Checkpoint: Select the compatible Stable Diffusion checkpoint.
- CLIP Text Encode (Prompt): Enter the positive prompt describing the image.
- CLIP Text Encode (Negative): Optionally describe elements to avoid, if supported by the model and workflow.
- Empty Latent Image: Set image dimensions and batch size.
- KSampler: Configure sampling steps, guidance, sampler, scheduler, and seed.
- VAE Decode: Convert the generated latent representation into an image.
- Save Image: Save the output to ComfyUI's output directory.
The exact nodes and settings depend on your model family. Use a workflow designed for your specific model rather than assuming that every Stable Diffusion generation uses the same configuration.
Example text 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.
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
Monitoring is important when running AI workloads on a dedicated GPU server.
Open a separate SSH session and run:
watch -n 1 nvidia-smi This refreshes the GPU status every second.
Pay attention to:
- 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: Show which applications are using the GPU.
You can also monitor system memory and disk capacity:
free -h df -h What if your workflow runs out of VRAM?
Try:
- Reducing image resolution.
- Reducing batch size.
- Closing unnecessary GPU workloads.
- Using a compatible lower-memory model or precision.
- Enabling a memory-saving option supported by your ComfyUI version.
Model offloading can help some workflows fit into available memory, but it may increase generation time because data needs 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 performance still depends on model selection and workflow design.
Choose a model that fits your workload
Select the model architecture, precision, and checkpoint size according to the image quality and speed you need.
Smaller or quantized models may reduce memory requirements, while larger models may need 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 record 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 workflows with teammates, and troubleshoot changes.
Remember that a workflow file does not necessarily include the model weights or custom nodes it depends on. 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 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
CUDA is not available
Possible causes include:
- CPU-only PyTorch was installed.
- The CUDA wheel is incompatible.
- The NVIDIA driver is not working correctly.
Check the driver:
nvidia-smi 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 current ComfyUI instructions.
CUDA out of memory
Possible causes include a large model, high image dimensions, a large batch size, or a workflow that exceeds available VRAM.
Try reducing the resolution and batch size, closing other GPU workloads, or using a compatible lower-memory model.
A checkpoint does not appear
Check that:
- The file is in the correct directory.
- The download completed successfully.
- The file is readable.
- The model uses the expected directory structure.
For a standard checkpoint, check:
models/checkpoints/ Refresh the model list or restart ComfyUI if necessary.
Missing nodes when opening a workflow
The workflow may depend on custom nodes that are not installed.
Identify the missing node packages, review their sources and compatibility, then follow their documentation to install them.
Do not install unknown node packages simply because a workflow requests them.
The web interface is not reachable remotely
Check that:
- ComfyUI is running.
- The service is listening on port
8188. - Your SSH tunnel is still open.
- The local browser is using the forwarded port.
- Server and local firewall rules allow the required connection.
Image generation is slower than expected
Confirm CUDA availability, monitor GPU utilization and memory, and test a simple workflow at a moderate resolution.
The workload may be limited by GPU performance, memory pressure, CPU processing, or expensive custom nodes.
11. Keep Your AI Image-Generation Server Secure
A ComfyUI server may contain proprietary workflows, model files, generated images, and access to powerful computing resources.
Treat it like any other production server.
Recommended practices:
- Keep Ubuntu, NVIDIA drivers, ComfyUI, PyTorch, and custom nodes updated through a controlled maintenance process.
- Use SSH keys where possible.
- Restrict inbound ports with a firewall.
- Keep port
8188private unless you have a deliberate, protected remote-access design. - Use HTTPS and authentication when providing browser access through a reverse proxy.
- Avoid sharing administrator credentials.
- Back up workflow JSON files, configuration, and important generated assets.
- Record model sources and licenses.
- Monitor disk space and remove only files you no longer need.
- Test updates in a separate environment before modifying a working production setup.
For a shared service, consider separating user 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 is useful when local hardware is limited or 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 being shared with unrelated desktop applications.
More GPU memory options: Select hardware based on the models and image dimensions you plan to use.
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 hardware availability and platform compatibility.
The right server depends on your model, expected image volume, concurrency, and budget. Estimate VRAM and storage requirements before selecting a configuration.
Conclusion
Running ComfyUI and Stable Diffusion on a dedicated GPU server provides a flexible environment for AI image generation, custom workflows, and persistent model storage.
The key steps are to:
- Match your GPU to the model and workflow.
- Install a compatible CUDA-enabled PyTorch build.
- Organize model files correctly.
- Verify GPU acceleration.
- Start with a simple text-to-image workflow.
- Protect remote access with appropriate security controls.
With regular updates, sensible backups, and secure access management, a dedicated GPU server can provide a dependable foundation for ongoing AI image-generation workloads.
Read the original COLO BIRD tutorial:
https://www.colobird.com/tutorials/howto/install-comfyui-stable-diffusion-gpu-server/
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.
Do I need an NVIDIA GPU to run ComfyUI?
No. ComfyUI supports multiple hardware platforms, but installation 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 loads compatible models and runs image-generation workflows.
How much VRAM do I need for Stable Diffusion?
There is no single VRAM requirement for every model. Memory use depends on model architecture, precision, image resolution, batch size, and workflow. Check the model documentation before selecting a GPU.
Where do I put Stable Diffusion checkpoint files in ComfyUI?
For a standard checkpoint workflow, place files in ComfyUI/models/checkpoints/. Other model architectures may require separate files in directories such as models/diffusion_models/ and models/text_encoders/.
Can I access ComfyUI from my local computer?
Yes. An SSH tunnel provides a straightforward way to access the server privately without making the ComfyUI port publicly accessible.
Can multiple users use one ComfyUI server?
Yes, but you should design access control, job scheduling, storage separation, and resource limits carefully. The default interface is not a complete multi-user access-control system.
Can I use custom models and LoRAs?
Yes, provided they are compatible with the workflow and ComfyUI version. Store each asset in its expected directory and check its publisher's 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 speed depends on the GPU, model, precision, workflow, resolution, and software configuration.
