MSDN Community AI & Machine Learning

Installation Guide

This guide will walk you through the essential steps to get your development environment ready for AI and Machine Learning projects on Windows.

Installing on Windows

We recommend using the Windows Subsystem for Linux (WSL) for a more seamless experience, but native Windows installations are also supported for many tools.

Option 1: Using WSL (Recommended)

WSL provides a Linux environment within Windows, offering better compatibility with many ML tools and libraries.

  1. Install WSL: Open PowerShell as Administrator and run:
    wsl --install
    This will install WSL and a default Linux distribution (usually Ubuntu). Follow the on-screen prompts to set up your Linux username and password.
  2. Update Linux Distribution: Once WSL is installed, open your Linux distribution (e.g., Ubuntu) and run:
    sudo apt update && sudo apt upgrade -y
  3. Install Python: Most Linux distributions come with Python pre-installed. You can check your version with:
    python3 --version
    If you need a specific version or a clean install, consider using a version manager like pyenv.
  4. Install Pip and Virtualenv:
    sudo apt install python3-pip python3-venv -y
  5. Create a Virtual Environment: It's best practice to use virtual environments for your projects.
    python3 -m venv myenv
    source myenv/bin/activate
    Your terminal prompt should now show (myenv).
  6. Install Core ML Libraries:
    pip install numpy pandas scikit-learn tensorflow pytorch
    (Note: For specific GPU acceleration with TensorFlow or PyTorch, refer to their official installation guides for CUDA and cuDNN.)

Option 2: Native Windows Installation

Some tools can be installed directly on Windows. This is often simpler for beginners but might have compatibility issues with advanced libraries.

  1. Install Python: Download the latest Python installer from python.org. Ensure you check "Add Python to PATH" during installation.
  2. Install Pip: Pip is usually included with Python installations.
  3. Create a Virtual Environment:
    python -m venv venv
    .\venv\Scripts\activate
    Your command prompt should now show (venv).
  4. Install Core ML Libraries:
    pip install numpy pandas scikit-learn tensorflow pytorch
    (For GPU support on native Windows, installing TensorFlow and PyTorch can be more complex due to driver and library dependencies.)
Pro Tip: Consider installing Visual Studio Code with the Python and AI/ML extensions for a superior development experience.

Installing on Linux (WSL)

This section assumes you have WSL 2 installed and a Linux distribution like Ubuntu ready.

  1. Update Package Lists:
    sudo apt update && sudo apt upgrade -y
  2. Install Python 3 and Pip:
    sudo apt install python3 python3-pip python3-venv -y
  3. Verify Installation:
    python3 --version
    pip3 --version
  4. Create and Activate Virtual Environment:
    python3 -m venv ~/ml_project_env
    source ~/ml_project_env/bin/activate
  5. Install Essential Libraries:
    pip install numpy pandas matplotlib scikit-learn jupyterlab
  6. Install Deep Learning Frameworks:
Note: If you plan on using GPU acceleration, ensure your NVIDIA drivers are installed correctly within WSL.

Installing on macOS

macOS provides a robust environment for AI and Machine Learning development.

  1. Install Homebrew (if not already installed): Homebrew is a package manager for macOS.
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Install Python:
    brew install python
    This will install the latest Python 3.
  3. Verify Python Installation:
    python3 --version
  4. Install Virtualenv:
    pip3 install virtualenv
  5. Create and Activate Virtual Environment:
    virtualenv ~/ml_env
    source ~/ml_env/bin/activate
    Your terminal prompt should now show (ml_env).
  6. Install Core ML Libraries:
    pip install numpy pandas matplotlib scikit-learn jupyterlab
  7. Install Deep Learning Frameworks:
    • TensorFlow: For macOS, especially with Apple Silicon (M1/M2 chips), TensorFlow has optimizations.
      pip install tensorflow-macos
      Refer to the Apple Metal plugin documentation for M-series chip acceleration.
    • PyTorch:
      pip install torch torchvision torchaudio
      Check the PyTorch website for the most up-to-date commands.

Verifying Your Installation

Once your environment is set up and libraries are installed, you can verify them by running a simple Python script. Create a file named verify_ml.py with the following content:

import sys
import numpy
import pandas
import sklearn
import tensorflow
import torch

print(f"Python version: {sys.version}")
print(f"NumPy version: {numpy.__version__}")
print(f"Pandas version: {pandas.__version__}")
print(f"Scikit-learn version: {sklearn.__version__}")
print(f"TensorFlow version: {tensorflow.__version__}")
print(f"PyTorch version: {torch.__version__}")

print("\nML libraries installed successfully!")

Activate your virtual environment (if you created one) and run the script:

# Example if using venv on Windows
.\venv\Scripts\activate
python verify_ml.py

# Example if using venv on Linux/macOS
source ~/ml_project_env/bin/activate
python verify_ml.py

If the script runs without errors and prints the versions of the installed libraries, your setup is complete!

1. Install Essential Tools

Set up your base environment with Python, Pip, and a virtual environment manager.

2. Install Core Libraries

Add fundamental data science and ML libraries like NumPy, Pandas, and Scikit-learn.

3. Install Deep Learning Frameworks

Install TensorFlow and/or PyTorch based on your project needs.

4. Configure GPU Support (Optional)

For performance, set up CUDA and cuDNN if you have a compatible NVIDIA GPU.