Intermediate

SageMaker Notebooks

Master SageMaker's notebook environments for data exploration, model development, and experimentation.

Studio Notebooks vs Notebook Instances

FeatureStudio NotebooksNotebook Instances
InterfaceJupyterLab (integrated)Jupyter / JupyterLab
Startup timeFast (seconds)Slower (minutes)
Instance switchingChange on the flyRequires restart
CollaborationShared spacesIndividual
Git integrationBuilt-inManual setup
Auto shutdownConfigurable idle timeoutLifecycle config required
Recommended✓ (default choice)Legacy / specific needs
💡
Recommendation: Use Studio Notebooks for most work. They offer faster startup, easier instance switching, built-in Git integration, and better collaboration features. Notebook Instances are still useful for specific cases like custom AMIs or long-running processes.

Instance Types

Choose the right instance type for your workload:

  • ml.t3.medium: General development, small datasets, code writing. Most cost-effective for learning
  • ml.m5.large/xlarge: Data preprocessing, medium datasets, feature engineering
  • ml.c5.xlarge: CPU-intensive computations, data transformations
  • ml.g4dn.xlarge: GPU-powered development, small model training, deep learning prototyping
  • ml.p3.2xlarge: Serious deep learning development with V100 GPU

Lifecycle Configurations

Lifecycle configurations are shell scripts that run when a notebook instance is created or started:

  • On-create scripts: Run once when the instance is first created - install persistent packages, configure tools
  • On-start scripts: Run every time the instance starts - activate environments, start services
  • Auto-shutdown: Configure scripts to automatically stop idle instances after a set period
  • Custom environments: Install specific Python packages, Conda environments, or system tools

Working with Data

SageMaker notebooks access data primarily through Amazon S3:

  • S3 integration: Use the SageMaker Python SDK or boto3 to read and write data to S3 buckets
  • Local storage: Notebook instances have attached EBS volumes for temporary local storage
  • EFS mounting: Mount Amazon EFS for shared, persistent file storage across notebooks
  • Athena queries: Query data lakes directly from notebooks using Amazon Athena
  • Data Wrangler: Use SageMaker Data Wrangler for visual data exploration and transformation

Pre-installed Kernels and Frameworks

💻

Python Kernels

Pre-configured environments with Python 3.x, pandas, numpy, scikit-learn, and the SageMaker SDK.

Deep Learning

TensorFlow, PyTorch, and MXNet kernels with GPU support configured automatically.

🔄

R Kernel

R kernel with tidyverse, caret, and integration with the SageMaker R SDK for R-based workflows.

📈

Spark

SparkMagic kernel for connecting to Amazon EMR clusters for distributed data processing.

Pro tip: Always use %%time or %%timeit magic commands in your notebooks to track cell execution time. This helps you identify bottlenecks and make informed decisions about when to scale up your instance type or offload work to SageMaker Processing jobs.

Ready to Go Deeper?

Live instructor-led courses from our partners. Affiliate disclosure.