Installation
Install the Python SDK to fine-tune on your own GPU, or use an API key to train in the Langtrain cloud.
- Python 3.8+
- Linux or WSL
- NVIDIA GPU
What you need
To train on your own machine:
- Linux, or Windows with WSL
- An NVIDIA GPU with a recent CUDA driver. With 4-bit QLoRA, 16 GB of GPU memory is enough for 7B and 8B models; 24 GB gives you room for longer examples
- Python 3.8 or later
Install
Use a virtual environment. langtrain-ai[train] brings in PyTorch, Transformers, PEFT, TRL, bitsandbytes and datasets; langtune is the training library underneath.
python
1python -m venv .venv2source .venv/bin/activate34pip install "langtrain-ai[train]" langtune
Vision models
Add the vision extra to fine-tune vision-language models with Langvision.
python
1pip install "langtrain-ai[vision]"
Check it works
Confirm the package imports and PyTorch can see your GPU.
python
1python -c "import langtrain; print('langtrain', langtrain.__version__)"2python -c "import torch; print('CUDA', torch.cuda.is_available(), torch.cuda.get_device_name(0) if torch.cuda.is_available() else '')"
API key (cloud only)
Local training needs no account. To start runs in the Langtrain cloud through the REST API, create a key in the dashboard under API keys. Leave it unset in the shell you train locally from: when it is set, Langtune sends runs to the cloud instead.
python
1export LANGTRAIN_API_KEY=sk-lt-...
Next
Train your first model with the Quick start.