✅ Full Guide: Running Jupyter Notebook on GPUs

This guide helps you set up Jupyter Notebook with GPU support using Anaconda, CUDA, cuDNN, and deep learning libraries like PyTorch or TensorFlow.


⚙️ Step 1: Install Anaconda

jupyter notebook

This opens Jupyter Notebook in your browser.


⚙️ Step 2: Install CUDA Toolkit

CUDA enables your Python libraries (e.g., TensorFlow, PyTorch) to run on NVIDIA GPUs.

nvidia-smi

⚙️ Step 3: Install cuDNN Library

cuDNN accelerates deep learning on GPUs.

After downloading: - Extract the files. - Copy bin/, lib/, and include/ folders into your CUDA installation directory (usually /usr/local/cuda/ on Linux).

⚠️ cuDNN must be manually installed — not via conda/pip.


⚙️ Step 4: Create a Conda Environment (Python 3.8)

conda create --name gpu_env python=3.8
conda activate gpu_env

⚙️ Step 5: Install Required Packages

Choose one of the following options depending on your framework preference:

🧠 Option A: TensorFlow + Keras (GPU-enabled)

conda install -c anaconda tensorflow-gpu keras-gpu
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

⚠️ Replace 11.8 with your actual CUDA version.

➕ Optional: Add data science packages

conda install jupyter numpy pandas matplotlib scikit-learn

⚙️ Step 6: Configure Jupyter to Use GPU Environment

python -m ipykernel install --user --name gpu_env --display-name "Python (GPU)"

✅ This registers the environment as "Python (GPU)" in the Jupyter kernel list.


🚀 Step 7: Launch Jupyter Notebook

jupyter notebook
  • Click New Notebook
  • Choose the "Python (GPU)" kernel

✅ Step 8: Verify GPU is Being Used

Run this in a notebook cell:

import torch
torch.cuda.is_available()

Expected Output:

True

If True, your environment is GPU-enabled. 🎉


🧠 Quick Troubleshooting

Problem Fix
torch.cuda.is_available() is False Make sure CUDA and cuDNN are properly installed
Kernel not showing in Jupyter Ensure you ran the ipykernel install command
Version mismatch / compatibility Match TensorFlow or PyTorch to your CUDA version
Model runs slow Check if code is accidentally running on CPU (torch.device("cuda"))

Once you configure the versions of CUDA, cudnn and jupyter, you go over steps 7 and 8 again and you should find your notebook running on GPU.

screenshot