Cg
Artificial Intelligence (AI) Azure

ComfyUI GPU on Ubuntu 24.04 on Azure User Guide

| Product: ComfyUI GPU on Ubuntu 24.04 LTS on Azure

Overview

ComfyUI is the open source, node-based studio for generative AI: you build a workflow by wiring nodes together (load a model, encode a prompt, sample, decode, save) and run it on your own GPU. This image runs ComfyUI 0.47.0 on Ubuntu 24.04 LTS with PyTorch 2.15 and the NVIDIA 580 data center driver, ready for an Azure NC T4 v3 VM (NVIDIA Tesla T4) or a larger NVIDIA GPU size. ComfyUI sits behind nginx on HTTPS, with a password made for your VM alone at its first boot. cloudimg's support team is on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours.

What is included:

  • ComfyUI 0.47.0 (GPL-3.0) with its web front end 1.59.15 and the built-in workflow templates, in a Python 3.12 virtual environment at /opt/comfyui/venv
  • PyTorch 2.15.0 and torchvision 0.29.2 built for CUDA 13.2
  • The NVIDIA 580 server driver (580.196.07) as Canonical's signed kernel modules for the Azure kernel, so the GPU works at first boot with no driver build, and nvidia-smi
  • NVIDIA cuDNN and cuSPARSELt, which PyTorch needs, installed from PyPI by your VM's first boot under NVIDIA's licence terms
  • nginx in front on ports 443 (HTTPS) and 80 (redirects to HTTPS), with HTTP Basic sign-in as admin and a 24-character password made at first boot, and a TLS certificate made for your VM's address
  • ComfyUI itself listening only on 127.0.0.1:8188, run by systemd as the unprivileged comfyui account
  • A dedicated 64 GB data disk at /var/lib/comfyui/models for your models, with the usual model folders ready
  • comfyui-gpu-check, which proves ComfyUI's PyTorch is driving your GPU
  • Partner API nodes (Comfy's paid cloud model nodes) turned off, so every workflow runs on your VM
  • No model weights in the image: you choose and download the models you want (Step 9)

Prerequisites

An active Azure subscription, an SSH key pair, and quota for an NVIDIA GPU VM size in your region. Standard_NC4as_T4_v3 (4 vCPU, 28 GiB RAM, one 16 GB NVIDIA Tesla T4) is the size this image is built and tested for; larger NC sizes give more GPU memory for bigger models. Azure counts these under Standard NCASv3_T4 Family vCPUs: if your quota for that family is 0, request an increase under Quotas in the Azure Portal before you deploy. The image also starts on a VM with no GPU, where ComfyUI runs on the CPU (very slowly). NSG inbound: allow 443/tcp (and 80/tcp for the redirect) and 22/tcp from your own network only. The VM needs outbound HTTPS at its first boot to install cuDNN and cuSPARSELt from PyPI.

Step 1 - Deploy from the Azure Marketplace

Sign in to the Azure Portal, choose Create a resource, search the Marketplace for ComfyUI GPU on Ubuntu 24.04 by cloudimg, and select Create. On Basics pick your subscription, resource group and a region that offers NC T4 v3, then See all sizes and choose Standard_NC4as_T4_v3. Under Administrator account choose SSH public key and paste your key; under Inbound port rules allow SSH (22) and HTTPS (443). Keep the data disk the image brings: it holds your models. Then Review + create -> Create. Once it is deployed, limit the NSG's 22 and 443 rules to your own address.

Step 2 - Deploy from the Azure CLI

# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn cloudimg1647283583153:comfyui-gpu:default:latest

az vm create \
  --resource-group <your-rg> \
  --name comfyui \
  --image cloudimg1647283583153:comfyui-gpu:default:latest \
  --size Standard_NC4as_T4_v3 \
  --admin-username azureuser \
  --ssh-key-values ~/.ssh/id_ed25519.pub \
  --public-ip-sku Standard

az network nsg rule create \
  --resource-group <your-rg> \
  --nsg-name comfyuiNSG \
  --name allow-https \
  --priority 1010 \
  --direction Inbound --access Allow --protocol Tcp \
  --destination-port-ranges 443 80 \
  --source-address-prefixes <your-address>/32

az vm create names the network security group after the VM (<vm-name>NSG); check its name with az network nsg list --resource-group <your-rg> -o table. Your VM's public address is in az vm show -d --resource-group <your-rg> --name comfyui --query publicIps -o tsv.

Step 3 - Connect to your VM

ssh azureuser@<vm-public-ip>

First boot takes about a minute after the VM starts: it installs cuDNN and cuSPARSELt, makes your password and certificate, then starts ComfyUI and nginx. The login message tells you where your sign-in details are.

Step 4 - Confirm ComfyUI is running

systemctl is-active comfyui nginx
curl -s http://127.0.0.1:8188/system_stats | jq '{comfyui: .system.comfyui_version, pytorch: .system.pytorch_version}'
active
active
{
  "comfyui": "0.47.0",
  "pytorch": "2.15.0+cu132"
}

ComfyUI answers only on the VM itself (127.0.0.1:8188); everyone else reaches it through nginx on 443, which asks for the password. The models disk is mounted and empty, ready for your models:

ComfyUI and nginx active, ComfyUI 0.47.0 with PyTorch 2.15.0, nginx on 80 and 443, ComfyUI on 127.0.0.1:8188, and the 63 GB models disk

Step 5 - Your sign-in details

sudo cat /root/comfyui-credentials.txt
# ComfyUI GPU on Ubuntu 24.04 LTS (cloudimg Azure Marketplace image)
# This VM's own sign-in, made at first boot. Keep this file private.
COMFYUI_URL=https://<VM address>/
COMFYUI_USERNAME=admin
COMFYUI_PASSWORD=<your password>
COMFYUI_GPU=Tesla T4
# The certificate is self-signed for this VM's address: your browser asks you to accept it once.
# Models go in /var/lib/comfyui/models (checkpoints, diffusion_models, text_encoders, vae, loras, ...).

COMFYUI_GPU names the GPU your VM's first boot found. The picture below was taken on cloudimg's build machine, which has no GPU, so there it reads none found; on an NC T4 v3 VM it reads Tesla T4.

The credentials file: the address, the admin user, the password (hidden here) and the GPU line

Step 6 - Sign in from your browser

Open the COMFYUI_URL (https://<your VM's public address>/). The certificate is one your VM made for itself, so your browser warns about it once: choose Advanced and continue. Your browser then asks for a user name and password: enter admin and the COMFYUI_PASSWORD. ComfyUI opens on its default template, Z-Image Turbo text to image. The red outlines mark the model loaders whose models are not on your VM yet, because the image ships no models:

ComfyUI's graph editor on first sign-in, showing the default Z-Image Turbo template with its two model loaders outlined until the models are downloaded

View details lists exactly which files the template needs and which models folder each goes in. Step 9 downloads them on the VM:

The Setup required panel listing qwen_3_4b.safetensors for text_encoders and z_image_turbo_bf16.safetensors for diffusion_models

The panel's Download buttons save the files to the computer your browser runs on, not to your VM, so use Step 9 instead.

Step 7 - Prove ComfyUI is using your GPU

sudo comfyui-gpu-check

It names your GPU, its driver and memory, runs a half-precision matrix multiply and a cuDNN convolution on the GPU in ComfyUI's own PyTorch, reads the device ComfyUI reports, and ends with GPU check passed. Anything else ends with GPU CHECK FAILED: and the reason (see Troubleshooting). nvidia-smi shows the GPU's load and memory while a workflow runs.

Step 8 - Run a workflow through the API

Everything the browser does goes through ComfyUI's HTTP API, so scripts can queue workflows too. Keep the password in a curl config file only you can read, rather than on the command line:

(umask 077; printf 'user = "admin:%s"\n' "$(sudo sed -n 's/^COMFYUI_PASSWORD=//p' /root/comfyui-credentials.txt)" > ~/.comfyui-curl)
curl -sk -o /dev/null -w 'without the password: %{http_code}\n' https://127.0.0.1/
curl -sk -K ~/.comfyui-curl -o /dev/null -w 'with the password: %{http_code}\n' https://127.0.0.1/
without the password: 401
with the password: 200

This workflow needs no model: it makes a 512 x 512 image, inverts its colours and saves it. Queue it and wait for the result:

cat > /tmp/comfyui-api-demo.json <<'EOF'
{"prompt": {
  "1": {"class_type": "EmptyImage", "inputs": {"width": 512, "height": 512, "batch_size": 1, "color": 2003199}},
  "2": {"class_type": "ImageInvert", "inputs": {"image": ["1", 0]}},
  "3": {"class_type": "SaveImage", "inputs": {"images": ["2", 0], "filename_prefix": "api-demo"}}
}}
EOF
ID=$(curl -sk -K ~/.comfyui-curl -H 'Content-Type: application/json' -d @/tmp/comfyui-api-demo.json https://127.0.0.1/prompt | jq -r .prompt_id)
echo "queued $ID"
until curl -sk -K ~/.comfyui-curl "https://127.0.0.1/history/$ID" | jq -e --arg id "$ID" '.[$id].outputs."3"' >/dev/null; do sleep 1; done
curl -sk -K ~/.comfyui-curl "https://127.0.0.1/history/$ID" | jq -r --arg id "$ID" '.[$id].outputs."3".images[].filename'
ls /var/lib/comfyui/output/
queued 3f09262f-54bf-48ef-81c1-d1ee39134d12
api-demo_00001_.png
api-demo_00001_.png

From another machine use https://<your VM's public address>/ in place of https://127.0.0.1/. To turn a workflow you built in the browser into this format, export it in API format from ComfyUI's workflow menu.

Without the password ComfyUI answers 401, with it 200, and the demo workflow saves api-demo_00001_.png

The same works in the browser. Here a picture is loaded, quantized to six colours and saved, and the result shows in the Save Image node:

A three-node workflow in ComfyUI: Load Image, Quantize Image and Save Image, with the input landscape and the six-colour result

Step 9 - Download models

Models go on the data disk under /var/lib/comfyui/models, in the folder their loader reads: checkpoints, diffusion_models, text_encoders, vae, loras, upscale_models, controlnet and the others already there. Download them as the comfyui account so ComfyUI can read them. Choose models whose licence allows your use: cloudimg ships none and grants no rights to any.

The default template uses Z-Image Turbo, which its authors publish under the Apache 2.0 licence. Its three files (about 19 GB) come from Comfy-Org's repackaged copy on Hugging Face:

cd /var/lib/comfyui/models
sudo -u comfyui curl -fL -o diffusion_models/z_image_turbo_bf16.safetensors https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/diffusion_models/z_image_turbo_bf16.safetensors
sudo -u comfyui curl -fL -o text_encoders/qwen_3_4b.safetensors https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/text_encoders/qwen_3_4b.safetensors
sudo -u comfyui curl -fL -o vae/ae.safetensors https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/vae/ae.safetensors

Reload ComfyUI in your browser: the red outlines go, and Run generates an image on your GPU. The first run takes longest, while the models load from disk into memory. For a model that needs a Hugging Face account, sign in on the VM with the Hugging Face CLI that is in ComfyUI's environment: sudo -u comfyui /opt/comfyui/venv/bin/hf auth login, then sudo -u comfyui /opt/comfyui/venv/bin/hf download <repo> <file> --local-dir <folder>.

Step 10 - Explore the nodes and templates

The Node Library (press n) holds every node this ComfyUI has, grouped by what they work on:

The Node Library sidebar, with its folders of model, image, latent, text, video and audio nodes

Templates in the left bar opens ready-made workflows for images, video, audio and 3D. Each names the models it needs, which you download as in Step 9. Templates built on Comfy's paid partner API nodes (cloud models such as those marked API) do not run on this image, because those nodes are turned off. A template whose models are larger than your GPU's memory may need a larger NC size.

Step 11 - ComfyUI settings and extra flags

ComfyUI starts with /usr/local/sbin/comfyui-run, which adds --cpu only when the VM has no NVIDIA GPU. To add ComfyUI command line flags, set them in /etc/default/comfyui:

sudo nano /etc/default/comfyui        # for example COMFYUI_EXTRA_ARGS="--preview-method auto"
sudo systemctl restart comfyui

Custom nodes go in /var/lib/comfyui/custom_nodes (owned by comfyui); install their Python requirements into /opt/comfyui/venv and restart ComfyUI. Only install custom nodes you trust: they run with the comfyui account's access to your models and outputs.

Step 12 - Keeping Ubuntu and the GPU driver up to date

Unattended upgrades are on, so Ubuntu's security updates install by themselves. The NVIDIA modules package follows the Azure kernel, so a kernel update brings the matching NVIDIA module with it; reboot when the login message says a restart is required, then run sudo comfyui-gpu-check. ComfyUI and PyTorch stay at the versions above, so a workflow that works today keeps working; cloudimg's newer images carry newer ComfyUI releases.

Server components

Component Version or setting Where
ComfyUI 0.47.0, front end 1.59.15 /opt/comfyui/app
Python environment Python 3.12.3, PyTorch 2.15.0 (CUDA 13.2), torchvision 0.29.2 /opt/comfyui/venv
NVIDIA driver 580.196.07 (nvidia-utils-580-server, linux-modules-nvidia-580-server-azure) kernel module nvidia
cuDNN, cuSPARSELt nvidia-cudnn-cu13 9.26.0.51, nvidia-cusparselt-cu13 0.8.1, installed from PyPI at first boot /opt/comfyui/venv
ComfyUI service comfyui.service, runs as comfyui, listens on 127.0.0.1:8188 /usr/local/sbin/comfyui-run
Web front door nginx 1.24, ports 80 (redirect) and 443 (TLS, HTTP Basic sign-in) /etc/nginx/sites-available/comfyui
Operating system Ubuntu 24.04.5 LTS, kernel 7.0 (linux-azure)

The NVIDIA module version, the driver packages, the cuDNN and cuSPARSELt pins and PyTorch's CUDA and cuDNN versions

Filesystem layout

Path What it holds
/var/lib/comfyui/models The 64 GB data disk: your models, in ComfyUI's model folders
/var/lib/comfyui/output, input, user Generated images, uploaded inputs, and your saved workflows and settings
/var/lib/comfyui/custom_nodes Custom nodes you add
/opt/comfyui/app, /opt/comfyui/venv ComfyUI and its Python environment
/root/comfyui-credentials.txt Your sign-in details (root only)
/etc/nginx/.comfyui.htpasswd, /etc/nginx/tls/ The password hash and your VM's certificate
/etc/default/comfyui Extra ComfyUI flags

The OS disk is a 30 GB disk with / (29 GB), /boot and /boot/efi; /mnt is the Azure temporary disk, whose contents are lost when the VM is stopped. Your outputs live on the OS disk under /var/lib/comfyui/output: copy the ones you want to keep elsewhere, for example with scp from your computer.

Managing the service

sudo systemctl status comfyui
sudo systemctl restart comfyui
sudo journalctl -u comfyui -f

sudo systemctl stop comfyui and start stop and start it; nginx is nginx.service. A restart drops any queued work.

On startup

At the first start of your VM, comfyui-firstboot.service runs once, before ComfyUI and nginx:

  1. It works out your VM's public address
  2. It installs NVIDIA cuDNN and cuSPARSELt into ComfyUI's environment from PyPI (comfyui-sdk-install)
  3. It makes the admin password and a TLS certificate for your VM's address
  4. It writes /root/comfyui-credentials.txt and the login message, then /var/lib/cloudimg/comfyui-firstboot.done

What it did is in its journal: sudo journalctl -u comfyui-firstboot. It runs only once (the marker file stops it), so there is nothing to turn off. If your VM's address changes, sudo cloudimg-set-public-address <new-address> makes a new certificate for it.

Troubleshooting

The browser cannot reach ComfyUI: check the NSG allows 443/tcp from your address, and that systemctl is-active comfyui nginx answers active twice. curl -sk -o /dev/null -w '%{http_code}\n' https://127.0.0.1/healthz on the VM should print 200.

The password is refused: use the COMFYUI_PASSWORD from /root/comfyui-credentials.txt with the user name admin; it is case sensitive.

ComfyUI is not running: sudo journalctl -u comfyui-firstboot shows whether first boot finished; if cuDNN could not be downloaded (no outbound HTTPS), fix the network and run sudo comfyui-sdk-install, then sudo systemctl restart comfyui. sudo journalctl -u comfyui -n 50 shows ComfyUI's own errors.

GPU CHECK FAILED or ComfyUI runs on the CPU: check the VM size is an NVIDIA GPU size (nvidia-smi should list the GPU). After a kernel update, reboot so the new kernel and its NVIDIA module load together, then sudo systemctl restart comfyui.

Out of GPU memory during a run: use a smaller model or image size, or a larger NC size. --lowvram in /etc/default/comfyui trades speed for memory.

Security recommendations

  • Allow 443 and 22 from your own addresses only: the password protects ComfyUI, and a narrow NSG keeps everyone else from trying it
  • Keep the credentials file private and give the password only to people who should run workflows on your GPU
  • Install custom nodes and models only from sources you trust: both can run code on your VM
  • Replace the self-signed certificate with one from your own certificate authority if others use the VM: put it in /etc/nginx/tls/comfyui.crt and comfyui.key and reload nginx (cloudimg-set-public-address makes a new self-signed one, so run it before, not after)
  • Keep unattended upgrades on, and run sudo comfyui-gpu-check after a reboot

Support

cloudimg's support team is on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours, covering deployment, GPU set-up, models and workflows.