This guide will walk you through setting up a complete development environment for deep learning, including VS Code, Anaconda, CUDA (for GPU support), PyTorch, and other essential libraries.
- Installing Anaconda
- Installing Visual Studio Code
- Opening VS Code from Anaconda
- Creating a New Conda Environment
- Installing CUDA and Checking GPU Availability
- Installing PyTorch and Essential Libraries
- Setting Up Jupyter Notebook
- Troubleshooting
- Visit Anaconda's download page
- Download the Windows installer (64-bit recommended)
- Run the downloaded
.exefile - During installation:
- Select "Install for Just Me"
- Choose the default installation location
- Important: Check "Add Anaconda to my PATH environment variable"
- Check "Register Anaconda as my default Python"
- Click "Install" and wait for the installation to complete
- Visit Anaconda's download page
- Download the macOS installer (64-bit recommended)
- Run the downloaded
.pkgfile - Follow the installation prompts
- During installation, select "Install for me only"
- Complete the installation
Open a terminal (Command Prompt on Windows or Terminal on macOS) and type:
conda --versionYou should see the version of conda that was installed.
- Visit the VS Code download page
- Click on the Windows download button
- Run the downloaded
.exefile - Accept the license agreement
- Choose the installation location
- In the "Select Additional Tasks" screen:
- Check all boxes, especially "Add to PATH"
- Click "Install" and wait for the installation to complete
- Visit the VS Code download page
- Click on the macOS download button
- Open the downloaded
.zipfile - Drag Visual Studio Code to the Applications folder
- Open VS Code from your Applications folder
- Open VS Code
- Press
Ctrl+Shift+X(Windows) orCmd+Shift+X(macOS) to open Extensions view - Search for and install these extensions:
- Python
- Jupyter
- Pylance
- IntelliCode
- Open Anaconda Navigator (search for it in your start menu or applications)
- In the Home tab, find VS Code in the list of applications
- Click "Launch"
Alternatively, you can open VS Code from the command line:
- Open Terminal (macOS) or Command Prompt/Anaconda Prompt (Windows)
- Type the following command:
codeIt's best practice to create a separate environment for each project to avoid dependency conflicts.
- Open Terminal (macOS) or Anaconda Prompt (Windows)
- Create a new environment with Python 3.10:
conda create -n deeplearning python=3.10- Activate the environment:
# On Windows
conda activate deeplearning
# On macOS/Linux
conda activate deeplearning- Open Anaconda Navigator
- Click on the "Environments" tab
- Click "Create" at the bottom
- Name your environment (e.g., "deeplearning")
- Select Python 3.10
- Click "Create"
- Check your GPU model and ensure it's CUDA-compatible
- Visit NVIDIA CUDA Downloads
- Select Windows, your version, and download type (typically exe local)
- Download and run the installer
- Choose "Express Installation"
- Restart your computer after installation
Note: Most newer Macs with M1/M2 chips don't use NVIDIA GPUs and rely on Metal instead of CUDA. If you have an older Mac with an NVIDIA GPU:
- Visit NVIDIA CUDA Downloads
- Select macOS and follow the installation instructions
- Restart your computer after installation
- Activate your conda environment:
conda activate deeplearning- Install PyTorch (temporary installation for testing):
# For Windows with CUDA
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
# For macOS with M1/M2
conda install pytorch torchvision torchaudio -c pytorch- Test GPU availability in Python:
python -c "import torch; print('GPU Available:', torch.cuda.is_available()); print('GPU Count:', torch.cuda.device_count()); print('GPU Name:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'N/A')"If you see "GPU Available: True", your GPU is correctly set up!
- Ensure your conda environment is activated:
conda activate deeplearning- Install PyTorch with GPU support (adjust CUDA version if needed):
# For Windows with NVIDIA GPU (CUDA 11.8)
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
# For macOS with M1/M2
conda install pytorch torchvision torchaudio -c pytorch
# For CPU only (no GPU)
conda install pytorch torchvision torchaudio cpuonly -c pytorch- Install essential data science and machine learning libraries:
conda install -c conda-forge numpy pandas matplotlib scikit-learn seaborn
# Deep learning specific libraries
pip install transformers datasets huggingface_hub tensorboard- Install additional useful libraries:
# General utilities
pip install tqdm pillow opencv-python
# For NLP
pip install nltk spacy gensim
# For visualization
pip install plotly
# For experiment tracking
pip install mlflow wandb- Ensure your conda environment is activated:
conda activate deeplearning- Install Jupyter:
conda install -c conda-forge jupyterlab notebook- From the terminal with your environment activated:
jupyter notebookThis will open Jupyter in your default web browser.
- Open VS Code
- Open a folder for your project
- Press
Ctrl+Shift+P(Windows) orCmd+Shift+P(macOS) - Type "Python: Select Interpreter" and select your
deeplearningenvironment - Create a new notebook:
- Click on the Explorer icon in the side bar
- Right-click in the Explorer pane
- Select "New File" and name it with
.ipynbextension
- VS Code will open the notebook with Jupyter integration
Create a new notebook and run the following code to test your setup:
import sys
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import torch
import torchvision
import transformers
print(f"Python version: {sys.version}")
print(f"NumPy version: {np.__version__}")
print(f"Pandas version: {pd.__version__}")
print(f"PyTorch version: {torch.__version__}")
print(f"Torchvision version: {torchvision.__version__}")
print(f"Transformers version: {transformers.__version__}")
print(f"CUDA available: {torch.cuda.is_available()}")
if torch.cuda.is_available():
print(f"CUDA device: {torch.cuda.get_device_name(0)}")- Windows: Reinstall Anaconda and make sure to check "Add Anaconda to my PATH"
- macOS: Add conda to your path by running:
export PATH=~/anaconda3/bin:$PATH # Add this line to your ~/.zshrc or ~/.bash_profile to make it permanent
- Make sure your GPU is CUDA-compatible
- Install the appropriate CUDA version for your PyTorch version
- Check NVIDIA driver installation
- Make sure your conda environment is activated
- Install the missing package:
pip install Xorconda install X
- Install ipykernel in your environment:
conda install ipykernel python -m ipykernel install --user --name=deeplearning
- Manually specify the interpreter path:
- Press
Ctrl+Shift+P(Windows) orCmd+Shift+P(macOS) - Type "Python: Select Interpreter"
- Click "Enter interpreter path"
- Navigate to your Anaconda installation and select the Python executable in your environment
- Press
- Check the documentation:
- Search for error messages on Stack Overflow
- Join relevant communities on Discord or Reddit
Congratulations! You now have a fully set up deep learning environment with VS Code, Anaconda, PyTorch, and all the essential libraries. Happy coding!