Rent a GPU

Guide · QLoRA · transformers, PEFT, bitsandbytes, TRL

How do you fine-tune an LLM with QLoRA on a rented GPU?

Last updated: · 5 min read

Quick answer

What GPU do you need to fine-tune an LLM with QLoRA?

QLoRA loads the base model in 4-bit and trains small adapters, so a 14B model (10 GB of weights) trains on one RTX 4090 at $0.37 per hour on RentGPUCrypto. A 70B model needs an A100 80GB or H100. Pay in Monero, Bitcoin or USDT, with no KYC and no email.

In brief
  • What QLoRA does: freezes the base model in 4-bit NF4 and trains low-rank adapters in bfloat16 on top.
  • Stack: transformers, PEFT, bitsandbytes and TRL's SFTTrainer, all installable with pip on the PyTorch image.
  • GPU rule of thumb: the 4-bit weights plus headroom for activations; long sequences need more.
  • Run it in tmux: a closed laptop must not stop a ten-hour run.
  • Keep the adapter, not just the merge: it weighs megabytes and vLLM can serve it directly.

Which GPU fits which base model for QLoRA?

The 4-bit weight sizes come from RentGPUCrypto's VRAM rule (FP16/BF16 2 bytes, FP8/Q8 1.06 bytes, Q4 0.56 bytes per parameter, x1.2 for the KV cache and runtime). Training adds activations, LoRA weights and optimiser state on top, which grow with sequence length and batch size.

QLoRA on RentGPUCrypto: base model, 4-bit weight size and a suitable single GPU
Base model4-bit weightsSuggested GPUVRAM of that GPUPrice per hour
Llama 3.1 8B5 GBRTX 409024 GB$0.37
Qwen3 14B10 GBRTX 4090 or RTX 509032 GB (RTX 5090)$0.52
Qwen3 32B22 GBL40S48 GB$0.99
Llama 3.3 70B47 GBA100 80GB or H10080 GB$1.19

Why QLoRA instead of a full fine-tune?

Because it cuts the memory bill by an order of magnitude while keeping most of the quality. A full fine-tune stores the weights, gradients and Adam states in high precision for every parameter. For a 70B model that means a multi-node cluster. QLoRA trains only adapter matrices, a tiny fraction of the parameters, against a frozen 4-bit copy of the model.

The original QLoRA paper fine-tuned a 65B model on a single card with the memory of an L40S (48 GB). According to RentGPUCrypto's VRAM calculator, Llama 3.3 70B in 4-bit takes 47 GB of weights, which is why an A100 80GB at $1.19 per hour is the usual single-card choice for that size.

How do you prepare the instance?

Launch one GPU with the PyTorch with CUDA · Ubuntu image, then add the training libraries. Install inside a virtual environment that can see the system PyTorch. For gated base models such as Llama, accept the licence on Hugging Face and log in with a token first. Put your dataset on the instance with rsync; the data transfer guide shows the commands.

Environment for QLoRA
python3 -m venv --system-site-packages ~/qlora && source ~/qlora/bin/activate
pip install -U transformers peft trl bitsandbytes datasets accelerate
hf auth login   # only for gated models
tmux new -s train

What does the training script look like?

About thirty lines: a 4-bit config, a LoRA config, a dataset and TRL's SFTTrainer. The example trains Qwen3 14B on trl-lib/Capybara, a chat dataset in the messages format that SFTTrainer formats with the model's chat template. Replace it with your own JSONL file of conversations. target_modules="all-linear" puts adapters on every linear layer, which the QLoRA authors found works better than attention-only adapters.

train_qlora.py
import torch
from datasets import load_dataset
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import LoraConfig, prepare_model_for_kbit_training
from trl import SFTConfig, SFTTrainer

model_id = "Qwen/Qwen3-14B"
bnb = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.bfloat16,
    bnb_4bit_use_double_quant=True,
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=bnb, device_map="auto")
model = prepare_model_for_kbit_training(model)

lora = LoraConfig(r=16, lora_alpha=32, lora_dropout=0.05,
                  target_modules="all-linear", task_type="CAUSAL_LM")
dataset = load_dataset("trl-lib/Capybara", split="train")

args = SFTConfig(
    output_dir="qlora-out",
    per_device_train_batch_size=2,
    gradient_accumulation_steps=8,
    gradient_checkpointing=True,
    learning_rate=2e-4,
    num_train_epochs=1,
    max_length=2048,
    bf16=True,
    logging_steps=10,
    save_steps=200,
)
trainer = SFTTrainer(model=model, args=args, train_dataset=dataset,
                     peft_config=lora, processing_class=tokenizer)
trainer.train()
trainer.save_model("qlora-out/final")

How do you avoid running out of memory?

Shorten sequences and shrink the per-device batch before you rent a bigger card. Activation memory grows with max_length times batch size, and gradient checkpointing trades some speed for a large cut in it.

In order of effect:

  • Lower max_length to the real length of your samples.
  • Set per_device_train_batch_size to 1 and raise gradient_accumulation_steps to keep the effective batch.
  • Keep gradient_checkpointing=True.
  • Use a lower LoRA rank, such as 8.

Watch nvidia-smi -l 5 in a second tmux pane during the first hundred steps; memory use is stable after that.

What do you do with the adapter afterwards?

Either serve the adapter on top of the base model, or merge it into a full-precision copy. vLLM loads LoRA adapters at start-up with --enable-lora, so the same GPU can serve several fine-tunes of one base. Merging needs the base model in bfloat16, which for Qwen3 14B means 36 GB of VRAM or a CPU merge.

Copy qlora-out off the instance before deleting it, since deletion wipes the disk. Serving is covered in the Llama 70B with vLLM guide.

Serve the base model with the adapter
vllm serve Qwen/Qwen3-14B \
  --enable-lora \
  --lora-modules my-adapter=./qlora-out/final \
  --max-model-len 8192

QLoRA fine-tuning: common questions

Can I fine-tune a 70B model with QLoRA on one GPU?

Yes, on an A100 80GB or an H100, with gradient checkpointing and short sequences. The 4-bit weights alone take 47 GB by RentGPUCrypto's rule, so an L40S with 48 GB leaves almost nothing for activations.

How long does a QLoRA run take?

It depends on the number of tokens in your dataset, the sequence length and the GPU. Run 50 steps first, read the time per step in the log, and multiply by the total steps before you buy a large block of hours.

Does bitsandbytes work on the RTX 5090?

Recent bitsandbytes releases support Blackwell when used with a CUDA 12.8 build of PyTorch. Install PyTorch from the cu128 index first, then bitsandbytes, and run a short test before the real job.

Can I train on several GPUs?

Yes, with accelerate launch and data parallelism, each card holding a 4-bit copy. For one model that does not fit on a card, rent a bigger GPU; QLoRA with model sharding is harder to set up.

What happens to my data when I delete the instance?

The local NVMe disk is wiped. While the instance is only stopped, the disk and your checkpoints stay. RentGPUCrypto does not read the files on your disk.

Verdict
  • Up to 14B: an RTX 4090 at $0.37 per hour is enough for QLoRA.
  • 32B: an L40S; 70B: an A100 80GB or H100.
  • Measure 50 steps first, then buy the block of hours that fits; unused hours never expire. See the fine-tuning use case for larger runs.
Sources (5)
  1. QLoRA: Efficient Finetuning of Quantized LLMs (Dettmers et al., 2023) — arXiv
  2. TRL SFTTrainer documentation — Hugging Face
  3. PEFT LoRA documentation — Hugging Face
  4. bitsandbytes 4-bit quantization in transformers — Hugging Face
  5. vLLM LoRA adapters — vLLM

Fine-tune on an A100 80GB

$11.90 for 10 GPU-hours, or $188.16 for a 168-hour block. Paid in crypto, no KYC.

RTX 4090 from $0.37/hr · no KYC

Rent a GPU