deeplearning-lab-ktu

Installation Guide

Complete guide for setting up Python and required dependencies for Deep Learning Labs on Windows, Ubuntu, and macOS.


Table of Contents


Python Installation

Windows

  1. Download Python
  2. Install Python ```
    • Run the installer
    • CHECK “Add Python to PATH”
    • Click “Install Now”
    • Wait for installation to complete ```
  3. Verify Installation
    python --version
    pip --version
    

Method 2: Microsoft Store

  1. Open Microsoft Store
  2. Search for “Python 3.10” or later
  3. Click “Get” to install
  4. Verify in Command Prompt:
    python --version
    

Method 3: Anaconda (For Data Science)

  1. Download Anaconda
  2. Run installer with default settings
  3. Open Anaconda Prompt and verify:
    python --version
    conda --version
    

Ubuntu/Linux

Method 1: APT Package Manager (Ubuntu/Debian)

  1. Update Package List
    sudo apt update
    sudo apt upgrade -y
    
  2. Install Python 3
    sudo apt install python3 python3-pip python3-venv -y
    
  3. Verify Installation
    python3 --version
    pip3 --version
    
  4. Create Aliases (Optional)
    echo "alias python=python3" >> ~/.bashrc
    echo "alias pip=pip3" >> ~/.bashrc
    source ~/.bashrc
    

Method 2: Deadsnakes PPA (Latest Python Versions)

  1. Add PPA Repository
    sudo apt update
    sudo apt install software-properties-common -y
    sudo add-apt-repository ppa:deadsnakes/ppa -y
    sudo apt update
    
  2. Install Python 3.10 (or later)
    sudo apt install python3.10 python3.10-venv python3.10-dev -y
    
  3. Install pip
    curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
    

Method 3: Build from Source

# Install dependencies
sudo apt install build-essential zlib1g-dev libncurses5-dev \
  libgdbm-dev libnss3-dev libssl-dev libreadline-dev \
  libffi-dev libsqlite3-dev wget libbz2-dev -y

# Download Python
cd /tmp
wget https://www.python.org/ftp/python/3.10.11/Python-3.10.11.tgz
tar -xf Python-3.10.11.tgz
cd Python-3.10.11

# Configure and install
./configure --enable-optimizations
make -j $(nproc)
sudo make altinstall

# Verify
python3.10 --version

macOS

  1. Install Homebrew (if not installed)
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  2. Install Python
    brew install python@3.10
    
  3. Verify Installation
    python3 --version
    pip3 --version
    
  4. Create Aliases (Optional)
    echo "alias python=python3" >> ~/.zshrc
    echo "alias pip=pip3" >> ~/.zshrc
    source ~/.zshrc
    

Method 2: Official Python Installer

  1. Download from python.org/downloads/macos
  2. Run the .pkg installer
  3. Follow installation wizard
  4. Verify in Terminal:
    python3 --version
    

Method 3: Anaconda

  1. Download Anaconda for macOS
  2. Run the installer
  3. Follow installation instructions
  4. Verify:
    python --version
    conda --version
    

Virtual Environment Setup

Using venv (Built-in)

Windows

# Navigate to project directory
cd path\to\dl-lab

# Create virtual environment
python -m venv venv

# Activate virtual environment
venv\Scripts\activate

# Deactivate when done
deactivate

Ubuntu/Linux & macOS

# Navigate to project directory
cd ~/path/to/dl-lab

# Create virtual environment
python3 -m venv venv

# Activate virtual environment
source venv/bin/activate

# Deactivate when done
deactivate

Using Conda

# Create environment
conda create -n dl-lab python=3.10 -y

# Activate environment
conda activate dl-lab

# Deactivate when done
conda deactivate

Installing Dependencies

Option 1: Full Installation (All Features)

# Activate your virtual environment first!

# Install all dependencies
pip install -r requirements.txt

# Verify installation
pip list

Option 2: Minimal Installation (Core Features Only)

# Activate your virtual environment first!

# Install minimal dependencies
pip install -r requirements-minimal.txt

# Verify installation
pip list

Manual Installation (If needed)

# Core dependencies
pip install torch torchvision torchaudio
pip install numpy matplotlib opencv-python pillow
pip install scikit-learn scipy tqdm

# Optional: For specific labs
pip install transformers  # For NLP labs
pip install tensorboard   # For visualization

GPU Support (Optional)

NVIDIA GPU (CUDA)

Windows & Linux

  1. Check GPU Compatibility
    nvidia-smi
    
  2. Install CUDA Toolkit
  3. Install PyTorch with CUDA
    # For CUDA 11.8
    pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
       
    # For CUDA 12.1
    pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
    
  4. Verify GPU Support
    import torch
    print(f"CUDA available: {torch.cuda.is_available()}")
    print(f"CUDA version: {torch.version.cuda}")
    print(f"GPU: {torch.cuda.get_device_name(0)}")
    

Apple Silicon (M1/M2/M3)

# PyTorch with MPS (Metal Performance Shaders) support
pip install torch torchvision torchaudio

# Verify MPS support
python -c "import torch; print(f'MPS available: {torch.backends.mps.is_available()}')"

Verification

Test Python Installation

python --version
pip --version

Test Package Installation

# Create test script: test_installation.py
import torch
import numpy as np
import cv2
import matplotlib.pyplot as plt
from PIL import Image

print("✓ All packages imported successfully!")
print(f"PyTorch version: {torch.__version__}")
print(f"NumPy version: {np.__version__}")
print(f"OpenCV version: {cv2.__version__}")

Run the test:

python test_installation.py

Run Sample Lab

# Test with Lab 1
cd lab_01_image_processing
python image_processing.py

Troubleshooting

Common Issues

1. “python: command not found”

Solution:

2. “pip: command not found”

Solution:

# Linux/macOS
python3 -m ensurepip --upgrade

# Windows
python -m ensurepip --upgrade

3. Permission Denied (Linux/macOS)

Solution:

# Don't use sudo with pip in virtual environment
# If outside venv, use --user flag
pip install --user package_name

4. SSL Certificate Error

Solution:

pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org package_name

5. Slow Download Speed

Solution:

# Use a mirror (example: Tsinghua mirror)
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple package_name

6. Conflicting Dependencies

Solution:

# Create fresh virtual environment
python -m venv fresh_venv
source fresh_venv/bin/activate  # or fresh_venv\Scripts\activate on Windows
pip install -r requirements.txt

7. CUDA Out of Memory

Solution:

8. Import Error: No module named ‘cv2’

Solution:

pip uninstall opencv-python opencv-python-headless
pip install opencv-python

Additional Resources

Documentation

Learning Resources

Community Support


Quick Reference

Essential Commands

# Check versions
python --version
pip --version

# Create virtual environment
python -m venv venv

# Activate venv
source venv/bin/activate        # Linux/macOS
venv\Scripts\activate           # Windows

# Install dependencies
pip install -r requirements.txt

# List installed packages
pip list

# Update pip
pip install --upgrade pip

# Deactivate venv
deactivate

Next Steps

After successful installation:

  1. Verify all packages are installed
  2. Read GETTING_STARTED.md
  3. Review README.md for lab overview
  4. Start with Lab 1: Image Processing
  5. Follow the learning path through all 10 labs

Need Help? Check the Troubleshooting section or create an issue in the repository.