Fine-tuning teaches an open model your own examples: a house style, a fixed output format, a narrow task. With LoRA you train a small adapter instead of the whole model, so a 7B model fits on a single rented GPU. This guide goes from data to a saved adapter, and shows where to keep the cost under control. For a shorter planning list, read the fine-tuning checklist first.
Before you rent anything
Work that does not need a GPU should happen on your own computer.
- Write down the goal and a test. One sentence on what the model should do, and 50 to 200 held-out examples to check it. Without a test set you cannot tell if training helped.
- Prepare the data. Remove duplicates and empty rows, remove personal data you do not need, and make sure you have the right to use what is left. A few hundred clean examples usually teach more than thousands of messy ones.
- Use a format your trainer reads. Chat-style records with a
messageslist of user and assistant turns are the most common. - Estimate the memory. With 4-bit loading (QLoRA), a 7B model's weights are around 4 to 5 GB; training adds the adapter, the optimizer state for it, and activations that grow with sequence length and batch size. A 24 GB GPU gives comfortable room. How much VRAM do you need? shows the arithmetic.
Step 1: Choose a training template
Apidly has fine-tuning templates, each a JupyterLab or browser tool with the libraries installed:
- Unsloth fine-tuning notebook: a notebook with Unsloth for fast LoRA and QLoRA runs. Minimum 8 GB.
- LLaMA-Factory: fine-tuning from a web page, with less code.
- Fine-tuning starter: JupyterLab with PyTorch,
transformersandpeft, used in the fine-tuning tutorial. Minimum 24 GB.
See the full list on the templates page. This guide uses the Unsloth notebook: start it here. At the time of writing it does not run on RTX 50-series and other Blackwell GPUs; Deploy marks those configurations.
Step 2: Deploy
- Open Deploy and use the GPU memory filter for 24 GB, then sort by Price, low to high. The RTX 4090 and RTX 3090 are typical 24 GB choices. Check the live price on each page, because it changes.
- Pick the template, name the server, and set the disk. Plan for the base model, your data, checkpoints and the result: at least two to three times the model size is a safe start.
- In the automation section on the last step, add a stop rule so a forgotten run cannot continue for days: a running time that is a little longer than you expect, a stop when the GPU is idle, or a spending limit. See Automation.
- Check Per hour and select Start my server.
The first start installs the tools, so JupyterLab can take several minutes to answer after the status shows Running. Billing is by second from Running, so do your preparation first.
Step 3: Open the notebook and upload your data
On the Connect tab select Open Jupyter. Upload your data file into the notebook folder with the file browser, or copy it from your computer with scp; see Move data to and from a server. If the model needs a licence, add your Hugging Face token as the HF_TOKEN variable when you launch, and keep it secret (Secrets).
Step 4: Load the model in 4-bit and add the adapter
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
"unsloth/Qwen2.5-7B-Instruct",
max_seq_length=2048,
load_in_4bit=True,
)
model = FastLanguageModel.get_peft_model(
model,
r=16,
lora_alpha=16,
target_modules=["q_proj", "k_proj", "v_proj", "o_proj"],
use_gradient_checkpointing="unsloth",
)
model.print_trainable_parameters()print_trainable_parameters() shows what share of the model you are training. It should be a small fraction of one percent to a few percent. The settings that matter:
ris the adapter's rank. A higher value can learn more and uses more memory. 8 to 16 is a normal start.max_seq_lengthsets the longest example. Lower it if you run out of memory.- Gradient checkpointing saves memory at some cost in speed.
Run nvidia-smi in a terminal now. Seeing how much memory the loaded model uses tells you how much room is left for training.
Step 5: Train a short run first
Format your records into text with the model's chat template, then train with TRL's trainer. Option names change between library versions, so check the notebook the template creates and the library's documentation for the exact arguments. The shape is:
from trl import SFTConfig, SFTTrainer
trainer = SFTTrainer(
model=model,
train_dataset=dataset,
args=SFTConfig(
output_dir="outputs",
per_device_train_batch_size=2,
gradient_accumulation_steps=4,
num_train_epochs=1,
learning_rate=2e-4,
logging_steps=5,
save_steps=100,
),
)
trainer.train()Do not start with the full dataset. Set max_steps=20 in the config, run, and confirm that the loss goes down, that memory stays within the GPU, and that checkpoints are written. A failed 20-step test costs a few minutes. A failed overnight run costs far more. When the test is healthy, remove max_steps and train for real.
If training stops with an out-of-memory error, lower the batch size (and raise gradient accumulation to compensate), shorten max_seq_length, or move to a GPU with more memory.
Step 6: Test on held-out examples
Run the tuned model on the test set from the start and compare its answers with the base model's on the same prompts. Read a sample yourself, since numbers alone hide problems such as repeated phrases or lost general ability. If the results are worse, the usual causes are noisy data, too many epochs or too high a learning rate.
Step 7: Save the adapter and copy it off the server
model.save_pretrained("lora_adapter")
tokenizer.save_pretrained("lora_adapter")The adapter is small, usually megabytes to a few hundred megabytes. Copy it, your training settings and the data version to storage you control. Write down the library versions so you can repeat the run. Then you can serve the result: load it on top of the base model in a model server, as in Run an open LLM with vLLM.
Step 8: Stop the server
Your work is only safe once it is copied off the server.
- Stop ends the compute charge and keeps the disk, which is still billed.
- Destroy ends all charges and deletes the disk. Check your copy first, because deleted data cannot be recovered.
For long runs that save checkpoints and can resume, an interruptible price may be lower, with the risk that the server is paused when demand rises. See Interruptible servers and make sure your training resumes from the last checkpoint.
Cost, in short
You pay by the second for the time the server runs, plus the disk. Short test runs, a stop rule and a clean shutdown are what keep a fine-tuning bill small. Look at live pricing for current rates. For a smaller first run with a ready-made example, try the fine-tuning tutorial, and when you are ready create an account.
Try what this guide shows
Start one of these templates on a rented GPU server. You see the price per hour before you start, and you pay by the second.
- TrainingJupyter workspace
Unsloth fine-tuning notebook
JupyterLab with Unsloth installed, for fine-tuning open language models faster and with much less GPU memory.
- Minimum GPU memory
- 8 GB
- Default disk
- 80 GB
- TrainingOpens in your browser
LLaMA-Factory (fine-tuning in the browser)
Fine-tune open language models from a web page, without writing code, behind a password.
- Minimum GPU memory
- 8 GB
- Default disk
- 80 GB
- TrainingJupyter workspace
Fine-tuning starter
JupyterLab with PyTorch, transformers, peft and accelerate installed for LoRA fine-tuning.
- Minimum GPU memory
- 24 GB
- Default disk
- 150 GB
Try it on a real GPU server
Create a free account and add a balance from $10. Servers are billed by the second, and the review step shows the price per hour before you request one.
Related guides
- A checklist for your first fine-tuning runSteps to prepare, run and finish a fine-tuning job on a rented GPU server without wasting time or money.
- How much VRAM do you need for LLMs and images?Work out how much GPU memory your model needs before you rent: a simple formula for language models, image models and fine-tuning, with worked examples.
- Run an open LLM with vLLM on a rented GPUServe Qwen or another open model behind an OpenAI-compatible API on a rented GPU with vLLM: pick the GPU, set the model, call it from code and stop when idle.