Appendices
Appendix D: Development Environment Setup

D.3 Python Environment Setup

We recommend Python 3.10 or 3.11 for LLM work. Python 3.12+ works but occasionally has compatibility issues with newer ML libraries. Code Fragment D.3.1 below puts this into practice.

Option A: Conda (Recommended)

This snippet creates a Conda environment and installs the core libraries needed for LLM development.

# Install Miniconda (lightweight Conda distribution)
# Download from: https://docs.conda.io/en/latest/miniconda.html

# Create environment with Python 3.11
conda create -n llm python=3.11 -y
conda activate llm

# Install PyTorch with CUDA 12.4 (Conda handles CUDA toolkit)
conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia
# Requires system Python 3.10+ and CUDA toolkit already installed
python -m venv llm-env
source llm-env/bin/activate  # Linux/macOS
# llm-env\Scripts\activate   # Windows

# Install PyTorch (check pytorch.org for the correct command)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
Code Fragment D.3.1: Creating a Conda environment and installing PyTorch with CUDA support. Conda bundles the CUDA toolkit, so no system-level CUDA installation is required.

Option B: venv + pip

This snippet sets up a virtual environment using venv and installs packages with pip.

Code Fragment D.3.2: Setting up a venv virtual environment and installing PyTorch with pip, specifying the CUDA 12.4 wheel index.
Version Pinning

Always pin your package versions in a requirements.txt or environment.yml file. ML library APIs change frequently, and an unpinned dependency can silently break your training pipeline after an update.