Generating images with AI

Tags: image generation, ai,

Added: 2025-11-24T00:00

Generating images with AI

AI image generation is not new any more, and produces some pretty good results.

I thought I'd try and get it running locally. However, I don't have an expensive GPU, so when I say locally, I mean in AWS. These are the steps I took.

Create an account on huggingface.co, and generate a token to use later.

The following instructions all worked in late November 2025, but as time passes, I imagine the various versions will change, and so you might have to adapt it somewhat. YMMV.

Start up a g5.2xlarge with 150GB disk. This will cost you about £1.20/hour, so shut it down when you've finished. To save you needing to compile kernel drivers, and install things, use the Deep Learning OSS Nvidia Driver AMI GPU PyTorch 2.8 (Ubuntu 24.04) 20251101 AMI. It has quite a few things pre-installed.

SSH in as ubuntu, and run the following commands.

source /opt/pytorch/bin/activate
git clone https://github.com/comfyanonymous/ComfyUI
cd ComfyUI
pip install -r requirements.txt --upgrade
pip install "numpy<2.0"
python -c "import torch; print(f'CUDA Available: {torch.cuda.is_available()}'); print(f'Device: {torch.cuda.get_device_name(0)}'); print(f'Torch Version: {torch.__version__}')"
cd custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager.git
cd ..
wget -O models/unet/flux1-dev-fp8.safetensors https://huggingface.co/Kijai/flux-fp8/resolve/main/flux1-dev-fp8.safetensors
wget -4 -O models/unet/flux1-dev-fp8.safetensors https://huggingface.co/Kijai/flux-fp8/resolve/main/flux1-dev-fp8.safetensors
wget -4 -O models/clip/clip_l.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors
wget -4 -O models/clip/t5xxl_fp8_e4m3fn.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors
wget -4 -O models/vae/ae.safetensors https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/ae.safetensors
wget -4 -O models/vae/ae.safetensors https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/ae.safetensors --header="Authorization: Bearer "
pip install requests websocket-client
python main.py --listen=127.0.0.1

Wait for the server to download things, and it should eventually say it's ready.
Once that's happened, you can use a CLI to generate images.

In another SSH session:
cd ~/ComfyUI
wget -4 https://files.calum.org/flux_final.json
wget -4 https://files.calum.org/cli.py

python cli.py "A mouse in a chef's hat. The mouse is walking on a tightrope, suspended between Big Ben and the Eiffel Tower."


The first generation takes a little while, as the server has to initialise stuff, but after that each image takes about 30 seconds.
The files are output to ~/ComfyUI/output/
This is the result.

Remember to shut down your instance when you've finished with it. However, you will still pay for the 150GB storage when it's shutdown.

Add a comment

Your IP:
Please enter 3941217 here: