Setting Up Your AI/ML Environment
Let's get your development environment ready for AI and machine learning projects! š ļø
System Requirementsā
Minimum Requirementsā
- RAM: 8GB (16GB recommended)
- Storage: 50GB free space
- OS: Windows 10+, macOS 10.14+, or Linux Ubuntu 18.04+
- Internet: Stable connection for downloading packages
Recommended Specificationsā
- RAM: 16GB+ for large datasets
- GPU: NVIDIA GPU with CUDA support (for deep learning)
- Storage: SSD for faster data loading
Step 1: Install Pythonā
Option A: Anaconda (Recommended for Beginners)ā
Why Anaconda?
- Pre-installed data science packages
- Environment management
- Cross-platform compatibility
- Jupyter Notebook included
Installation Steps:
-
Download Anaconda
# Visit: https://www.anaconda.com/products/distribution
# Download Python 3.9+ version for your OS -
Install Anaconda
- Windows: Run the
.exe
installer - macOS: Run the
.pkg
installer - Linux: Run the
.sh
script
- Windows: Run the
-
Verify Installation
conda --version
python --version
Option B: Python + pip (For Experienced Users)ā
# Install Python 3.9+
# Windows: Download from python.org
# macOS: brew install python
# Linux: sudo apt-get install python3 python3-pip
# Verify installation
python --version
pip --version
Step 2: Create a Virtual Environmentā
Using Conda (Recommended)ā
# Create a new environment
conda create -n ai-ml python=3.9
# Activate the environment
conda activate ai-ml
# Deactivate when done
conda deactivate
Using pip + venvā
# Create virtual environment
python -m venv ai-ml-env
# Activate environment
# Windows:
ai-ml-env\Scripts\activate
# macOS/Linux:
source ai-ml-env/bin/activate
# Deactivate
deactivate
Step 3: Install Essential Librariesā
Core Data Science Stackā
# Activate your environment first
conda activate ai-ml
# Install essential packages
conda install numpy pandas matplotlib seaborn scipy scikit-learn
# Or using pip
pip install numpy pandas matplotlib seaborn scipy scikit-learn
Deep Learning Frameworksā
TensorFlow + Kerasā
# CPU version
pip install tensorflow
# GPU version (requires CUDA)
pip install tensorflow-gpu
PyTorchā
# CPU version
conda install pytorch torchvision torchaudio cpuonly -c pytorch
# GPU version (CUDA 11.7)
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
Additional Useful Librariesā
# Jupyter for interactive development
pip install jupyter jupyterlab
# Computer vision
pip install opencv-python pillow
# Natural language processing
pip install nltk spacy transformers
# Web scraping and APIs
pip install requests beautifulsoup4
# Visualization
pip install plotly bokeh
# Model deployment
pip install streamlit flask fastapi
Step 4: Set Up Development Environmentā
Option A: Jupyter Notebook/Labā
# Start Jupyter Notebook
jupyter notebook
# Or Jupyter Lab (recommended)
jupyter lab
Jupyter Features:
- Interactive code execution
- Rich output display
- Markdown documentation
- Easy sharing
Option B: VS Codeā
Install VS Code:
- Download from https://code.visualstudio.com/
Essential Extensions:
- Python
- Jupyter
- Python Docstring Generator
- GitLens
VS Code Configuration:
// settings.json
{
"python.defaultInterpreterPath": "~/anaconda3/envs/ai-ml/bin/python",
"jupyter.askForKernelRestart": false,
"python.linting.enabled": true,
"python.linting.pylintEnabled": true
}
Option C: PyCharmā
Features:
- Intelligent code completion
- Built-in debugger
- Scientific tools
- Professional IDE features
Step 5: GPU Setup (Optional but Recommended)ā
Check GPU Compatibilityā
# Check if GPU is available
import tensorflow as tf
print("TensorFlow GPU available:", tf.test.is_gpu_available())
# For PyTorch
import torch
print("PyTorch GPU available:", torch.cuda.is_available())
print("CUDA version:", torch.version.cuda)
Install CUDA (NVIDIA GPUs)ā
- Check GPU compatibility: https://developer.nvidia.com/cuda-gpus
- Download CUDA Toolkit: https://developer.nvidia.com/cuda-downloads
- Install cuDNN: https://developer.nvidia.com/cudnn
Step 6: Verify Installationā
Create a test script to verify everything works:
# test_setup.py
import sys
print(f"Python version: {sys.version}")
# Test core libraries
try:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import sklearn
print("ā
Core data science libraries installed successfully!")
except ImportError as e:
print(f"ā Missing library: {e}")
# Test deep learning frameworks
try:
import tensorflow as tf
print(f"ā
TensorFlow {tf.__version__} installed")
print(f"GPU available: {tf.test.is_gpu_available()}")
except ImportError:
print("ā TensorFlow not installed")
try:
import torch
print(f"ā
PyTorch {torch.__version__} installed")
print(f"CUDA available: {torch.cuda.is_available()}")
except ImportError:
print("ā PyTorch not installed")
# Test Jupyter
try:
import jupyter
print("ā
Jupyter installed")
except ImportError:
print("ā Jupyter not installed")
print("\nš Setup verification complete!")
Run the test:
python test_setup.py
Troubleshooting Common Issuesā
Import Errorsā
# Update pip
python -m pip install --upgrade pip
# Reinstall problematic package
pip uninstall package_name
pip install package_name
Environment Issuesā
# List environments
conda env list
# Remove corrupted environment
conda env remove -n ai-ml
# Recreate environment
conda create -n ai-ml python=3.9
GPU Issuesā
- Ensure CUDA version matches PyTorch/TensorFlow requirements
- Check GPU drivers are up to date
- Verify GPU has sufficient memory
Next Stepsā
Once your environment is set up, proceed to Python Basics to refresh your Python skills for AI/ML development.
Quick Reference Commandsā
# Environment management
conda create -n myenv python=3.9
conda activate myenv
conda deactivate
conda env list
# Package management
conda install package_name
pip install package_name
conda list
pip list
# Jupyter
jupyter notebook
jupyter lab
# Update packages
conda update --all
pip install --upgrade package_name
š” Pro Tip: Always work in virtual environments to avoid package conflicts and maintain project isolation!