Environment Setup Guide
This guide will help you set up your development environment for the AI Engineering Syllabus.
—
๐ Python Installation
Option 1: Anaconda (Recommended for Beginners)
Download: https://www.anaconda.com/download
Advantages:
- Includes Python + many libraries
- Easy environment management
- Works on Windows/Mac/Linux
Installation:
Create environment for AI course
conda create -n ai-course python=3.9
conda activate ai-course
Option 2: Python.org (Lightweight)
Download: https://www.python.org/downloads/
Install Python 3.9+
Create virtual environment:
python -m venv ai-envActivate (Linux/Mac)
source ai-env/bin/activateActivate (Windows)
ai-env\Scripts\activate
—
๐ฆ Essential Libraries
Core Libraries
Numerical computing
pip install numpy scipy pandasVisualization
pip install matplotlib seabornMachine learning
pip install scikit-learnDeep learning
pip install torch torchvision torchaudioJupyter notebooks
pip install jupyter ipykernelProgress bars
pip install tqdm
Additional Libraries (Install as needed)
Computer vision
pip install opencv-python pillow albumentationsNLP
pip install transformers tokenizers sentencepieceOptimization
pip install optunaDeployment
pip install fastapi uvicorn gradio streamlitModel export
pip install onnx onnxruntimeMemory profiling
pip install memory-profiler psutilExperiment tracking
pip install wandb tensorboard
All-in-One Installation
Save this as requirements.txt:
numpy>=1.21.0
scipy>=1.7.0
pandas>=1.3.0
matplotlib>=3.4.0
seaborn>=0.11.0
scikit-learn>=1.0.0
torch>=2.0.0
torchvision>=0.15.0
jupyter>=1.0.0
tqdm>=4.62.0
opencv-python>=4.5.0
pillow>=9.0.0
albumentations>=1.3.0
fastapi>=0.100.0
uvicorn>=0.23.0
gradio>=3.40.0
onnx>=1.14.0
onnxruntime>=1.15.0
memory-profiler>=0.60.0
psutil>=5.9.0
optuna>=3.3.0
Then install:
pip install -r requirements.txt
—
๐ป Development Tools
1. VS Code (Recommended)
Download: https://code.visualstudio.com/
Essential Extensions:
- Python (Microsoft)
- Jupyter (Microsoft)
- Pylance (Microsoft)
- GitLens (optional)
Settings:
{
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.provider": "black",
"editor.formatOnSave": true
}
2. Jupyter Lab/Notebook
Install
pip install jupyterlabRun
jupyter labOr classic notebook
jupyter notebook
3. Git
Download: https://git-scm.com/
Setup:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
—
๐ง Platform-Specific Optimizations
Linux
Intel MKL (Math Kernel Library):
conda install mkl mkl-service
OpenBLAS:
sudo apt-get install libopenblas-dev
Verify:
import numpy as np
np.show_config()
Windows
Install WSL2 (Windows Subsystem for Linux):
1. Open PowerShell as Administrator
2. Run: wsl --install
3. Restart computer
4. Install Ubuntu from Microsoft Store
5. Follow Linux setup above
Why WSL2?
- Better performance for ML workloads
- Access to Linux tools
- Easier package management
macOS
Accelerate Framework (Built-in):
import numpy as np
NumPy automatically uses Accelerate on macOS
Homebrew (Package manager):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
—
๐งช Verify Installation
Create test_setup.py:
import sys
print(f"Python version: {sys.version}")import numpy as np
print(f"NumPy version: {np.__version__}")
import torch
print(f"PyTorch version: {torch.__version__}")
print(f"CUDA available: {torch.cuda.is_available()}")
import sklearn
print(f"scikit-learn version: {sklearn.__version__}")
Test NumPy speed
import time
size = 5000
a = np.random.rand(size, size)
b = np.random.rand(size, size)start = time.time()
c = np.dot(a, b)
end = time.time()
print(f"Matrix multiplication ({size}x{size}): {end-start:.2f}s")
print("โ
Setup successful!")
Run:
python test_setup.py
Expected output:
- Python 3.9+
- NumPy, PyTorch, scikit-learn versions
- Matrix multiplication < 5 seconds
—
๐ Memory Monitoring Tools
1. htop (Linux/Mac)
Install
sudo apt-get install htop # Linux
brew install htop # MacRun
htop
2. Task Manager (Windows)
Press Ctrl + Shift + Esc
3. Python Memory Profiler
from memory_profiler import profile@profile
def my_function():
a = [1] (10 * 6)
b = [2] (2 10 7)
del b
return a
my_function()
—
๏ฟฝ๏ฟฝ Docker (Optional)
Download: https://www.docker.com/get-started
Why Docker?
- Consistent environment across machines
- Easy deployment
- Isolate projects
Basic Dockerfile:
FROM python:3.9-slimWORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "main.py"]
Build and run:
docker build -t my-ai-project .
docker run -p 8000:8000 my-ai-project
—
โ๏ธ Configuration Tips
1. Increase Jupyter Memory Limit
Edit ~/.jupyter/jupyter_notebook_config.py:
c.NotebookApp.max_buffer_size = 1024 1024 1024 # 1GB
2. Set PyTorch Threads
import torch
torch.set_num_threads(4) # Use 4 CPU cores
3. Disable GPU (if you don’t have one)
import os
os.environ['CUDA_VISIBLE_DEVICES'] = ''
—
๐ Troubleshooting
“ModuleNotFoundError”
Make sure you're in the right environment
which python
pip listReinstall the package
pip install
“Out of Memory” during training
Reduce batch size
batch_size = 16 # Instead of 32Use gradient accumulation
See ISL_OPTIMIZATION_GUIDE.md
Slow NumPy operations
Check if MKL is installed
python -c "import numpy as np; np.show_config()"Install MKL
conda install mkl
Jupyter kernel crashes
Increase memory limit
Or restart kernel and clear outputs
—
โ Setup Checklist
- [ ] Python 3.9+ installed
- [ ] Virtual environment created and activated
- [ ] Essential libraries installed (NumPy, PyTorch, scikit-learn)
- [ ] Jupyter Lab/Notebook working
- [ ] VS Code installed with Python extension
- [ ] Git installed and configured
- [ ] Test script runs successfully
- [ ] Memory monitoring tool installed
—
๐ You’re Ready!
Once everything is set up, start with:
Module 1: Understanding AI & Smart Computing
Happy coding! ๐