AI

How to Run FLUX AI Image Generator Locally

FLUX is the model family that set the current bar for local image generation. You can run it on your own GPU with no cloud account, no per-image credits, and no queue in front of you. This guide uses the official Black Forest Labs repository to install FLUX.1, generate real images from the command line and a browser, and it is honest about the one thing most tutorials get wrong: how much VRAM these models actually need.

Original content from computingforgeeks.com - post 171852

We cover the whole path: which model to pick, real VRAM numbers from our own runs, getting Hugging Face access (yes, even the free model is gated now), installing the repo, and generating with FLUX.1 [schnell] and FLUX.1 [dev]. If you would rather drive everything through a graphical workflow, our Stable Diffusion on Linux setup builds the same kind of rig on ComfyUI. Everything here was tested in September 2026 against the official repo at commit 802fb47, on two NVIDIA cards: a 48 GB RTX A6000 that runs the full bf16 models, and a 24 GB RTX 4090 that shows exactly where they stop fitting.

The FLUX models, in one minute

Black Forest Labs ships FLUX in tiers. Two of them are open weights you download and run yourself. The rest sit behind a hosted API. Knowing which is which saves you from chasing a model you cannot actually run at home.

ModelBest forLicenseRuns locally?
FLUX.1 [schnell]Fast drafts, 4 stepsApache 2.0Yes (HF login)
FLUX.1 [dev]Best open-weight qualityNon-commercialYes (HF login)
FLUX.1 Kontext [dev]Editing an image by instructionNon-commercialYes (HF login)
FLUX.1 [pro] / 1.1 [pro]Top quality, hostedCommercial APINo
FLUX.2 [dev]Newer 32B flagshipNon-commercialYes, large VRAM
FLUX.2 [klein] 4BSmall, fully openApache 2.0Yes (no login)

For a first run, start with schnell. It finishes in four steps and its Apache-2.0 license allows commercial use. Move to dev when you want the extra detail and can accept its non-commercial license. One thing that trips people up: as of September 2026 the FLUX.1 weights are gated on Hugging Face, schnell included, so you need a free account and a token even for the permissive model. The only FLUX you can pull with no login at all is the newer FLUX.2 [klein] 4B.

How much VRAM do you need to run FLUX?

This is where most guides oversell what a 24 GB card can do. FLUX.1 [schnell] and [dev] are 12-billion-parameter models, and at bf16 the transformer alone is a 23.8 GB checkpoint. That barely fits the memory of a 24 GB card before you add the text encoder, the autoencoder, or a single activation. In our tests a stock 24 GB RTX 4090 ran out of memory on both schnell and dev, even with the repo’s --offload flag. The 48 GB RTX A6000 ran the same models comfortably, peaking at just over 24 GB of VRAM once the text encoder was pushed to system RAM.

ModelParamsPeak VRAM (bf16)Path on 24 GB or less
FLUX.1 schnell / dev12B~24 GB, needs a bigger cardfp8 in ComfyUI or TensorRT, ~12 to 16 GB
FLUX.2 [klein] 4B4B~13 GB~7 GB fp8, fits most modern cards
FLUX.2 [klein] 9B9B~29 GB~14 GB fp8, ~11 GB Q4 GGUF
FLUX.2 [dev]32B~64 GB~32 GB fp8, ~19 GB Q4 in ComfyUI

Error: “torch.OutOfMemoryError: CUDA out of memory” on a 24 GB card

On the 24 GB 4090, every bf16 run ended the same way, a few hundred megabytes short of loading the transformer:

torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 126.00 MiB. GPU 0 has a total capacity of 23.51 GiB of which 32.62 MiB is free. Of the allocated memory 23.09 GiB is allocated by PyTorch, and 12.64 MiB is reserved by PyTorch but unallocated.

The number that matters is “of which 32.62 MiB is free”. The transformer had already claimed the whole card. The --offload flag does not rescue this, because it moves the text encoders to system RAM, not the 12-billion-parameter transformer, and the transformer is what does not fit. Two paths get FLUX.1 onto a 24 GB card: run an fp8 build, which roughly halves the transformer and loads in 12 to 16 GB (the repo’s TensorRT path, or fp8 weights in ComfyUI), or step up to a card with more than 24 GB. The bf16 walkthrough below was run on the 48 GB A6000.

Budget disk too, and budget more than you expect. A single FLUX.1 model, its text encoders, and the autoencoder come to roughly 45 GB. The repo also keeps a second copy of each checkpoint under checkpoints/ in addition to the Hugging Face cache, so with both schnell and dev pulled our disk usage sat near 110 GB. Give a fresh box at least 60 GB per model.

What you need

  • An NVIDIA GPU with more than 24 GB of VRAM for the bf16 models. We used a 48 GB RTX A6000. On a 24 GB card the bf16 path runs out of memory, so reach for fp8 weights in ComfyUI instead. A working driver and CUDA runtime must already be in place, which our NVIDIA driver and CUDA install covers for Ubuntu.
  • Python 3.10 or newer, plus git.
  • A free Hugging Face account, because the FLUX.1 weights are gated.
  • At least 60 GB of free disk per model you keep.

No card with that much VRAM at home? These same commands run unchanged on a cloud GPU rented by the hour. A 48 GB card goes for well under a dollar an hour, which works out cheaper than most credit-based image services once you generate in volume.

Install FLUX

Clone the repository and create a virtual environment so FLUX keeps its dependencies to itself:

git clone https://github.com/black-forest-labs/flux
cd flux
python3 -m venv .venv
source .venv/bin/activate

Install the package with its demo extras. This is the step that pulls in PyTorch with CUDA support, so it takes a few minutes:

pip install -e ".[all]"

Confirm PyTorch actually sees the GPU before you download any weights:

python -c "import torch; print(torch.__version__, torch.cuda.get_device_name(0))"

The Torch build and card name should print back:

2.6.0+cu124 NVIDIA RTX A6000

Error: “ImportError: libxcb.so.1: cannot open shared object file”

On a minimal or headless box (a fresh cloud GPU, a server with no desktop), the first run crashes here. FLUX pulls in opencv-python for its Canny and Depth conditioners, and OpenCV needs a couple of system libraries that a bare install does not ship. Install them and the import succeeds:

sudo apt install -y libgl1 libglib2.0-0 libxcb1

Get access to the FLUX weights

This is the step most tutorials still get wrong. Black Forest Labs gates the FLUX.1 weights on Hugging Face, and as of September 2026 that includes schnell, despite its Apache-2.0 license. Pull them without logging in and the download stops with a 401. Two actions unlock it.

First, open the model page for the version you want while logged in to Hugging Face and click Agree and access repository. Do this once per model, per account. It approves instantly:

  • FLUX.1-schnell, the Apache-2.0 model. The gate is a formality here.
  • FLUX.1-dev, which asks you to accept its non-commercial license.

Second, create a read token under your Hugging Face account settings, then log in on the machine. The old huggingface-cli command is deprecated; the current tool is hf:

hf auth login

Paste the token when prompted. FLUX reads it automatically on the next run, so there is nothing else to configure.

Error: “Cannot access … this is a gated repository”

Skip either action above and generation stops before it ever loads the model:

Error: Cannot access black-forest-labs/FLUX.1-schnell -- this is a gated repository.

It means the account is not logged in, or it is logged in but has not clicked Agree and access repository on that model. Do both, then retry. An authenticated request to a model you have not agreed to returns a 403 with GatedRepo; a request with no token at all returns a 401.

Generate your first image with FLUX.1 [schnell]

With access sorted, generate. The text-to-image entry point is flux t2i. Add --offload so only the transformer sits in VRAM; without it the T5 text encoder loads onto the GPU as well and the run needs far more, over 30 GB. The first run downloads the weights, caches them, then samples. schnell is tuned for four steps:

python -m flux t2i --name flux-schnell --width 1024 --height 1024 \
  --seed 12345 --offload \
  --prompt "a red fox sitting in a snowy pine forest at dawn, cinematic photorealistic, sharp focus" \
  --output_dir ~/out

Run it and the session looks like this, from the GPU check through to the saved file:

Running FLUX.1 schnell from the command line with python -m flux t2i

The run reports its own timing. With offload shuttling the encoders in and out, schnell’s four steps completed in about 42 seconds and peaked at just over 24 GB of VRAM:

Generating with seed 12345:
a red fox sitting in a snowy pine forest at dawn, cinematic photorealistic, sharp focus
Done in 42.1s. Saving ~/out/img_0.jpg

Here is what schnell produced for that prompt, straight from the model with no post-processing:

FLUX.1 schnell output: a red fox sitting in a snowy pine forest at dawn

When you are iterating on a prompt, reloading the model each time is the slow part, not the sampling. Run it in a loop and it keeps the weights resident while you type prompts one after another:

python -m flux t2i --name flux-schnell --loop --offload

Higher quality with FLUX.1 [dev]

dev renders finer detail and follows prompts more closely than schnell. It is guidance-distilled and defaults to 50 sampling steps rather than four, so a single image takes noticeably longer. Once you have accepted its license on the model page, the command is the same with a different model name:

python -m flux t2i --name flux-dev --width 1024 --height 1024 \
  --seed 12345 --offload \
  --prompt "a red fox sitting in a snowy pine forest at dawn, cinematic photorealistic, sharp focus" \
  --output_dir ~/out

The same prompt on dev finished its 50 steps in about 88 seconds and peaked at just over 24 GB. The extra steps show in the fur texture and the light through the trees:

FLUX.1 dev output: the same red fox prompt rendered with finer detail at 50 steps

One licensing note worth repeating: the dev weights are non-commercial. For paid work, generate with schnell, which is Apache-2.0, or license dev and the pro models through Black Forest Labs.

Use FLUX from a browser

The repository ships two demo UIs. The Gradio one is a single command and gives you a prompt box, size sliders, and a seed field:

python demo_gr.py --name flux-schnell --device cuda --offload

Add --share for a public gradio.live link if you are on a remote box and want to reach it from your laptop. There is a Streamlit version too:

streamlit run demo_st.py

These demos are enough for quick prompting, but they stop at plain text-to-image. For LoRAs, upscaling, inpainting, and node-based pipelines, ComfyUI is the better home and it runs Flux natively, including the fp8 builds that fit a 24 GB card. The same GPU that renders these images also runs local LLMs, so one card covers both jobs. If you are monitoring a box that generates around the clock, our GPU monitoring with DCGM setup graphs VRAM and utilization so you can catch a job that is thrashing offload.

Where FLUX.2 fits

FLUX.2 arrived in November 2025 and is the current flagship. FLUX.2 [dev] is a 32B model, so its appetite for VRAM is in a different class: roughly 64 GB at bf16, about 32 GB at fp8, or near 19 GB with Q4 GGUF quantization in ComfyUI. If your card is 24 GB or less, the open FLUX.2 [klein] 4B model is the one to reach for. It is Apache-2.0, runs in about 13 GB, and unlike the FLUX.1 repos it is not gated, so no Hugging Face login is needed to pull it.

FLUX.2 lives in its own repository, but the shape of the work is identical to what you just did: clone, install, pull weights, generate. Deciding what to run at home is mostly a VRAM question, the same one that governs running local LLMs. Start on FLUX.1 with the steps here, get comfortable with prompts and seeds, and step up to FLUX.2 when your card and your output demands both grow.

Keep reading

Ollama Models Cheat Sheet: Best Models by VRAM, Tested (PDF) AI Ollama Models Cheat Sheet: Best Models by VRAM, Tested (PDF) Open Source LLM Comparison Table (2026) AI Open Source LLM Comparison Table (2026) OpenCode CLI Cheat Sheet: Commands, Sessions and Fixes (PDF) AI OpenCode CLI Cheat Sheet: Commands, Sessions and Fixes (PDF) Best Laptops for Local LLMs: RTX 50 vs 128GB Unified Memory AI Best Laptops for Local LLMs: RTX 50 vs 128GB Unified Memory Black Friday Mini PC Deals: Proxmox, Local AI and Home Assistant AI Black Friday Mini PC Deals: Proxmox, Local AI and Home Assistant Best Frigate Detector by Box: Hailo vs Coral vs Intel iGPU AI Best Frigate Detector by Box: Hailo vs Coral vs Intel iGPU

Leave a Comment

Press ESC to close