How do I train a FLUX LoRA with AI Toolkit on a cloud GPU?

Cover: Train a FLUX LoRA with AI Toolkit on a cloud GPU

Deploy a Raw GPU, install Ostris AI Toolkit from its GitHub README, log in to Hugging Face with access to FLUX.1-dev, upload a folder of images with same-name .txt captions, copy the example config train_lora_flux_24gb.yaml, point it at your folder and run python run.py (or use the AI Toolkit web UI through an SSH tunnel), then copy the finished .safetensors LoRA to your computer before you destroy the instance.

Updated 2026-10-29

This guide follows the official AI Toolkit README and its example config train_lora_flux_24gb.yaml, both read on 2026-10-29. It is for people who train character or style LoRAs and want a rented NVIDIA GPU such as the RTX 5090 or the other NVIDIA cards listed on /pricing instead of their own card.

Step 1: Deploy a Raw GPU and connect

On /deploy, pick an NVIDIA GPU and the Raw GPU option (JupyterLab + CUDA pre-installed, root SSH). Note the SSH host, port and user from your dashboard; you need them in Steps 6 and 7. Open a terminal in JupyterLab or connect over SSH.

VRAM need depends on model, precision and workflow; for image models see How much VRAM do I need for FLUX and SDXL?. The 24gb in the example config name is the upstream file name, not a fit check for your card or dataset.

Step 2: Check the environment first

nvidia-smi          # GPU name, driver version and the highest "CUDA Version" the driver supports
nvcc --version      # CUDA toolkit compiler, if installed
python3 --version   # the README asks for python >= 3.10 (3.12 recommended)
git --version

According to the official AI Toolkit README, the manual Linux install uses PyTorch wheels from the cu130 index (CUDA 13.0). If the “CUDA Version” in the nvidia-smi header is lower than that, those wheels will not run on the driver; see How to install a specific PyTorch CUDA version on a cloud GPU before you continue.

Step 3: Install AI Toolkit

The README’s manual Linux installation, in a virtual environment inside the repo:

git clone https://github.com/ostris/ai-toolkit.git
cd ai-toolkit
python3 -m venv venv
source venv/bin/activate
# install torch first
pip3 install --no-cache-dir torch==2.13.0 torchvision==0.28.0 torchaudio==2.11.0 --index-url https://download.pytorch.org/whl/cu130
pip3 install -r requirements.txt
python3 -c "import torch; print(torch.__version__, torch.cuda.is_available())"

The last line should print True. These version pins are the ones in the README on 2026-10-29; if the README has changed, use its current command.

The README also describes an experimental AI Toolkit Manager (python3 -m manager install, then python3 -m manager launch) that picks a PyTorch build, creates the environment, fetches local copies of Node.js and FFmpeg and starts the web UI. Either route works; this guide uses the manual install for the command-line path in Step 5 and the UI in Step 6.

Step 4: Get access to FLUX.1-dev and prepare your dataset

Before you use a base model, check the licence on its official model page: FLUX.1-dev, FLUX.1-schnell. FLUX.1-dev is a gated repository on Hugging Face: on its model page, request access, create a read token in your Hugging Face settings, then log in on the instance. AI Toolkit also bundles a FLUX.1-schnell example config, config/examples/train_lora_flux_schnell_24gb.yaml. According to the official Hugging Face CLI docs:

hf auth login

AI Toolkit downloads the base model on the first run. For where the files go and how to point the cache elsewhere, see How to download a Hugging Face model on a cloud GPU.

According to the README’s dataset rules:

  • Use a folder of jpg, jpeg or png images (the README says webp currently has issues).
  • Next to each image, put a text file with the same name holding only the caption: image2.jpg and image2.txt.
  • Write [trigger] in a caption and it is replaced with the trigger_word from your config.
  • You do not need to crop or resize. Images are never upscaled; larger ones are downscaled and bucketed.
dataset/
  01.jpg
  01.txt   # [trigger] standing in a kitchen, morning light
  02.png
  02.txt   # [trigger] close-up portrait, studio background

Upload the folder from your computer, for example with scp -P <ssh-port> -r ./dataset <ssh-user>@<ssh-host>:~/dataset, or drag it into the JupyterLab file browser.

Step 5: Copy the example config and train from the command line

The README’s training steps are: copy the example config into the config folder, edit it following its comments, then run it.

cd ~/ai-toolkit
cp config/examples/train_lora_flux_24gb.yaml config/my_flux_lora.yaml
nano config/my_flux_lora.yaml

The fields most people change, as named in the example file:

config:
  name: "my_first_flux_lora_v1"        # folder and file name of the run
  process:
    - type: 'sd_trainer'
      training_folder: "output"        # where checkpoints and samples go
      trigger_word: "p3r5on"           # uncomment and set your own word
      save:
        save_every: 250                # save a checkpoint every N steps
        max_step_saves_to_keep: 4
      datasets:
        - folder_path: "/root/dataset" # your image folder (check with pwd)
      train:
        steps: 2000
      model:
        name_or_path: "black-forest-labs/FLUX.1-dev"
      sample:
        sample_every: 250              # sample images every N steps
        prompts:
          - "[trigger] holding a coffee cup, sitting at a cafe"

Run it inside tmux so the job keeps going if your SSH connection drops:

tmux new -s lora
source venv/bin/activate
python run.py config/my_flux_lora.yaml
# detach with Ctrl+B then D; reattach with: tmux attach -t lora

According to the README, a folder named after your config is created under the training folder and “will have all checkpoints and images in it”. You can stop with Ctrl+C and, when you run the same command again, training picks back up from the last checkpoint. The README warns that pressing Ctrl+C while it is saving will likely corrupt that checkpoint, so wait until the save finishes. Watch nvidia-smi in a second window; if the GPU looks idle, see How to check GPU utilization on a cloud GPU.

Step 6 (optional): Use the AI Toolkit web UI over an SSH tunnel

According to the README, the UI is for starting, stopping and monitoring jobs, it serves on port 8675, and jobs keep running without it. If you host it on a cloud machine, the README “highly” recommends setting an auth token with AI_TOOLKIT_AUTH. With the manual install the UI needs Node.js newer than 20 (node --version):

cd ~/ai-toolkit/ui
AI_TOOLKIT_AUTH=<a-long-random-password> npm run build_and_start

Then forward the port from your computer and open http://localhost:8675:

ssh -p <ssh-port> -N -L 8675:localhost:8675 <ssh-user>@<ssh-host>

See How to use SSH port forwarding on a cloud GPU for the tunnel options.

Step 7: Copy the LoRA off the instance, then destroy it

According to /terms, data on the instance is permanently deleted when you destroy it, and instances are destroyed automatically when your balance reaches zero. Copy the run folder (the final .safetensors LoRA, the kept checkpoints and the sample images) to your computer first:

scp -P <ssh-port> -r <ssh-user>@<ssh-host>:~/ai-toolkit/output/my_first_flux_lora_v1 ./my_first_flux_lora_v1

Billing stops when you destroy the instance; GPU time is billed per minute, rounded up, with a 1-minute minimum. See /terms.

For card choices for LoRA work, see Rent a GPU for LoRA fine-tuning; to generate images with FLUX.1-dev afterwards, see /run/flux-1-dev.

FAQ

What does AI Toolkit need in a LoRA dataset?

According to the AI Toolkit README, a folder of jpg, jpeg or png images, each with a text file of the same name that holds only its caption, such as image2.jpg and image2.txt. You do not need to crop or resize the images, and webp currently has issues.

Which config file do I start from for a FLUX LoRA?

The README says to copy config/examples/train_lora_flux_24gb.yaml into the config folder, rename it, edit it following the comments in the file, and run it with python run.py config/your_file.yml.

Can I stop AI Toolkit training and resume it later?

Yes. According to the README, you can stop training with Ctrl+C and it picks back up from the last checkpoint when you run the same config again. Do not press Ctrl+C while a checkpoint is saving, because that will likely corrupt it.

How do I open the AI Toolkit UI on a cloud GPU?

Start the UI on the instance with an AI_TOOLKIT_AUTH token, then forward port 8675 with ssh -L 8675:localhost:8675 and open http://localhost:8675 in your browser. According to the README, jobs keep running even if the UI is stopped.

What happens to my LoRA when I destroy the instance?

It is deleted. The CloudGPU terms say data on the instance is permanently deleted when the instance is destroyed, so copy the output folder to your computer before you destroy it. Billing stops when you destroy the instance.