Fine-Tuning Open Source Models on Cloud GPUs: A Practical Guide
Fine-tuning adapts a pre-trained model to your specific domain, task, or style. Instead of training from scratch — which costs millions in compute — you start from a capable open-source model and teach it your data for a fraction of the cost. A single RTX 3090 rented at $0.15/hr can fine-tune a 7B-parameter model in under two hours. This guide covers the practical decisions: which models to fine-tune, which techniques to use, how much GPU you need, and what it costs.
Why Fine-Tune Instead of Prompt Engineering?
Prompt engineering works for simple tasks — classification, extraction, summarization. But when you need the model to internalize domain-specific patterns (medical terminology, legal reasoning, code style conventions), fine-tuning embeds that knowledge into the model weights. A fine-tuned 7B model often outperforms a prompted 70B model on narrow-domain tasks.
Fine-tuning also reduces prompt length. Instead of prepending 2,000 tokens of examples and instructions to every request, you bake that knowledge into the model. At scale, shorter prompts reduce inference cost proportionally.
Choosing a Base Model
The base model determines the ceiling of fine-tuning quality. Start with the best open-source model that fits your GPU budget:
| Base Model | Parameters | Min GPU VRAM (FP16) | Min GPU VRAM (QLoRA) | Best For |
|---|---|---|---|---|
| Llama 3.2 3B | 3B | 8 GB | 4 GB | Classification, extraction, simple chat |
| Mistral 7B | 7B | 16 GB | 6 GB | General-purpose, balanced quality/cost |
| Llama 3 8B | 8B | 18 GB | 8 GB | Strong reasoning, better multilingual |
| Qwen 2.5 14B | 14B | 30 GB | 12 GB | Code, math, structured tasks |
| Llama 3 70B | 70B | 160 GB | 40 GB | Maximum quality, complex reasoning |
For most fine-tuning tasks on a single RTX 3090 (24 GB VRAM), Mistral 7B or Llama 3 8B with QLoRA is the practical ceiling.
Fine-Tuning Techniques
Full Fine-Tuning
All model parameters are updated during training. Produces the best results but requires the most VRAM — the full model, optimizer states, and gradients must fit in GPU memory simultaneously.
VRAM requirement: roughly 4× the model size in FP16. A 7B model (14 GB in FP16) requires about 56 GB VRAM — beyond a single RTX 3090. Full fine-tuning 7B+ models typically requires 2–4 GPUs.
Cost: 4× RTX 3090 ($0.60/hr) for 4 hours = $2.40 per fine-tune.
LoRA (Low-Rank Adaptation)
Freezes the base model weights and trains small "adapter" matrices inserted between layers. A LoRA adapter for a 7B model is typically 10–50 MB — trainable on a single consumer GPU.
VRAM savings: 60–70% vs full fine-tuning. A 7B model that requires 56 GB for full fine-tuning fits in 18–22 GB with LoRA.
Quality: matches or exceeds full fine-tuning for most domain adaptation tasks. Slightly underperforms full fine-tuning on tasks requiring fundamental capability changes (e.g., teaching a new language).
Cost: 1× RTX 3090 ($0.15/hr) for 2 hours = $0.30 per fine-tune.
QLoRA (Quantized LoRA)
LoRA applied to a 4-bit quantized base model. Further reduces VRAM by keeping the frozen base model in 4-bit precision while training LoRA adapters in FP16.
VRAM: a 7B model fits in 6–8 GB with QLoRA. A 70B model fits in 40 GB — within a single A100.
Quality: within 1% of LoRA quality for most tasks. The quantization introduces negligible degradation because the trainable adapters remain in full precision.
Cost: 1× RTX 3090 ($0.15/hr) for 2 hours = $0.30 per fine-tune. 70B model on A100 ($1.20/hr) for 6 hours = $7.20 per fine-tune.
DPO (Direct Preference Optimization)
Instead of supervised fine-tuning on examples, DPO trains on preference pairs — "Response A is better than Response B." Used to align models with human preferences after supervised fine-tuning.
VRAM: similar to LoRA. DPO trains the same adapter structure; only the loss function changes.
Use case: refining a model's tone, reducing hallucinations, improving instruction-following after initial supervised fine-tuning.
Dataset Preparation
Size Requirements
| Task Complexity | Minimum Examples | Recommended Examples |
|---|---|---|
| Classification (binary) | 100 | 500–1,000 |
| Classification (multi-class) | 500 | 1,000–5,000 |
| Named entity recognition | 500 | 1,000–5,000 |
| Summarization | 1,000 | 2,000–5,000 |
| Instruction-following | 1,000 | 5,000–10,000 |
| Domain chat / Q&A | 2,000 | 5,000–20,000 |
More data is better, but diminishing returns set in around 5,000–10,000 examples for most tasks. Data quality matters more than quantity — 500 carefully curated examples often outperform 5,000 noisy ones.
Formatting
Most fine-tuning frameworks expect instruction-tuning format:
{
"instruction": "Classify the following text as positive, negative, or neutral.",
"input": "The GPU rental experience was smooth and the pricing was transparent.",
"output": "positive"
}
For chat models, the chat template format:
{
"messages": [
{"role": "system", "content": "You are a helpful GPU cloud assistant."},
{"role": "user", "content": "What is the cheapest GPU for fine-tuning?"},
{"role": "assistant", "content": "An RTX 3090 at $0.15/hr with QLoRA can fine-tune a 7B model for under $0.50."}
]
}
Cost Breakdown: Fine-Tuning a 7B Model
| Component | QLoRA (RTX 3090) | LoRA (RTX 3090) | Full (4× RTX 3090) |
|---|---|---|---|
| GPU rental | $0.30 (2 hrs @ $0.15/hr) | $0.45 (3 hrs @ $0.15/hr) | $2.40 (4 hrs @ $0.60/hr) |
| Storage (dataset + checkpoints) | $0.10 (S3 @ $2.49/TB) | $0.10 | $0.10 |
| Data egress (download model) | $0 (zero-egress provider) | $0 | $0 |
| Total | $0.40 | $0.55 | $2.50 |
Fine-tuning a 7B model costs less than a cup of coffee. Even a 70B model with QLoRA on an A100 costs about $8–$12.
Evaluating Fine-Tuned Models
Holdout Validation
Reserve 10–20% of your dataset for evaluation. Do not train on it. After fine-tuning, measure:
- Accuracy / F1 score. For classification and extraction tasks.
- Perplexity. For generative tasks. Lower is better, but perplexity alone does not capture task-specific quality.
- Human evaluation. For chat and summarization. Have a domain expert review 50–100 outputs for correctness, relevance, and tone.
Overfitting Detection
If validation loss increases while training loss decreases, the model is memorizing the training data instead of generalizing. Fixes: reduce training epochs, increase dataset size, add dropout, or reduce learning rate.
Benchmark Comparison
Compare against the unfine-tuned base model and against the best available API model (GPT-4o mini, Claude Haiku) on your specific task. The goal is not to beat the API on every metric — it is to be good enough for your use case at a fraction of the per-token cost.
Deployment After Fine-Tuning
LoRA/QLoRA adapters are separate from the base model. To serve:
- Load the base model on a GPU (same GPU type used for fine-tuning).
- Load and merge the LoRA adapter (or serve with the adapter separate, which adds negligible latency).
- Serve via vLLM, text-generation-inference, or llama.cpp server.
A fine-tuned 7B model on an RTX 3090 serves 8–16 concurrent users at $0.15/hr total. The inference cost per token is the same as the base model — the adapter adds no overhead.
Frequently Asked Questions
Can I fine-tune without coding experience?
Tools like Axolotl, Unsloth, and Hugging Face AutoTrain provide no-code and low-code fine-tuning interfaces. You upload a dataset in CSV or JSON format, select a base model, and click "train." The quality ceiling is lower than hand-tuned training, but for simple tasks it works well.
How do I know if my dataset is good enough?
Train a model on 20% of your data and evaluate. Then train on 50% and evaluate again. If performance improves meaningfully, your data contains signal. If not, the data may be too noisy or the task may not benefit from fine-tuning — prompt engineering may be sufficient.
How long does fine-tuning take?
Rule of thumb: 1 epoch on 5,000 examples takes approximately 30–60 minutes for a 7B model with QLoRA on an RTX 3090. A 3-epoch training run on 10,000 examples takes 3–6 hours. Scale linearly with dataset size and number of epochs.
Can I fine-tune on multiple GPUs?
Yes. LoRA and QLoRA support distributed data-parallel training across multiple GPUs using DeepSpeed or FSDP. Multi-GPU training reduces wall-clock time but does not reduce total GPU-hours — two GPUs finish in half the time at twice the hourly cost.
BHK Cloud offers RTX 3090 instances at $0.15/hr with per-minute billing and zero egress fees — ideal for QLoRA fine-tuning 7B models for under $0.50. No minimum commitment. Start fine-tuning or explore S3 storage at $2.49/TB/month.