unsloth or peft already installed, it’s a good idea to remove them first.unsloth → Main library that simplifies loading, fine-tuning, and exporting LLMs.trl → Hugging Face’s “Transformers Reinforcement Learning” library, used here for supervised fine-tuning.peft → Parameter-Efficient Fine-Tuning library that powers LoRA and other lightweight adaptation methods.accelerate → Handles efficient training across CPUs/GPUs.bitsandbytes → Provides 4-bit and 8-bit quantization for reduced GPU memory usage.transformers → Hugging Face Transformers library to load and manage models and tokenizers.datasets → Makes it easy to load and process training datasets in different formats (JSON, CSV, etc.).pdfplumber → Used to extract clean, structured text from your resume PDF.tiktoken → Tokenizer library for efficient token counting (useful when managing dataset sizes).sentencepiece → Required for certain tokenizers, including Google’s Gemma models.safetensors → A safe and efficient format for storing model weights. This is optional but useful if you need to convert or share models.NOTE : We need python version below 3.12 to make this work , latest version doesn’t support Unsloth. Also if using NVIDIA GPU install CUDA version that is supported by PyTorch - https://developer.nvidia.com/cuda-toolkit-archive VS Code → Terminal → New Terminal, then run:
# Create a folder for your project
mkdir gemma_finetune_project
cd gemma_finetune_project
# Create virtual environment
py -3.11 -m venv .venv
On Windows PowerShell:
.venv\Scripts\Activate
You should now see (.venv) prefix in your terminal — that means venv is active.
With venv activated, install everything you need:
# OPTIONAL: Clean up old conflicting installs
pip uninstall -y unsloth peft
# ✅ Step 1: Install PyTorch stack with specific CUDA version (don't skip index)
pip3 install torch torchvision torchaudio --index-url <https://download.pytorch.org/whl/cu129>
# ✅ Step 2: Install core ML + fine-tuning libraries WITHOUT touching torch
pip install --no-deps unsloth trl peft accelerate bitsandbytes transformers datasets
# ✅ Step 3: Install Unsloth Zoo separately
pip install diffusers xformers==0.0.27.post2 --no-deps
pip install unsloth_zoo
# ✅ Step 4: PDF/Text helpers
pip install pdfplumber tiktoken sentencepiece
# ✅ Step 5: Optional model storage utility
pip install safetensors
NOTE : If all goes wrong rebuild the virtual environment from scratch using the below command.
COMMAND : deactivate; Remove-Item -Recurse -Force .venv; python -m venv .venv; .\.venv\Scripts\Activate.ps1