Service Workbench
  • General User Guide
    • Introduction
    • Studies
      • Open Data Studies
      • Controlled Data Studies
        • Human Connectome
        • TCGA (The Cancer Genome Atlas)
        • EMory BrEast Imaging Dataset (EMBED)
      • Organization Studies
    • Research workspaces
      • Workspace statuses
      • Workspace configurations
      • How can I create a workspace linked to a study?
      • How can I create a workspace WITHOUT a study?
      • Installing packages into workspaces
      • Using custom Jupyter Notebook kernels
      • Uploading data into SWB
    • Instances
    • Example Analyses & Notebooks
    • FAQ
      • Why was my workspace stopped when I was working on it?
      • How can I install devtools in R/Rstudio?
      • I don't see a 'studies' folder in my workspace?
      • Error: 'Forbidden' or 'Unable to connect'
      • Error: 'We have a problem! null is not an object'...
      • 403 error page
      • Error provisioning environment sagemaker
      • Workspace in Unknown status
      • Cannot connect to SageMaker workspace
      • I can't get through to the log-in page on SWB.
    • Help / Contact Us
    • Release Notes
  • AIM-AHEAD
    • Accessing OCHIN Data
      • Phase 1: Regulatory Requirements
      • Phase 2: Data Exploration
      • Phase 3: Data Analysis
      • Example Researcher Workflow
    • Understanding the OCHIN Data
      • i2b2 Common Data Model
      • Example Queries
      • Additional information
  • Harvard Medical School
    • Introduction
    • Activating your account
    • Creating your workspace
  • LEAP-DEV
    • Workspace Configurations
Powered by GitBook
On this page
  • Creating a custom kernel
  • Existing custom kernels
  1. General User Guide
  2. Research workspaces

Using custom Jupyter Notebook kernels

When working with Jupyter Notebooks in SageMaker workspaces, you may want to create a custom kernel for your R or python notebooks. This will prevent you from needing to install and load packages ever

PreviousInstalling packages into workspacesNextUploading data into SWB

Last updated 7 months ago

Creating a custom kernel

Step 1: Create a SageMaker workspace using one of the kernels workspace types

When you create your SageMaker workpace, you will see different options for workspace configuration available. Select one with the word "kernels", such as "Sagemaker-Custom-Kernels-Medium".

Step 2: Open a Terminal window

Step 3: Log in as an administrator by running sudo su ec2-user

Step 4: Create a new kernel

Create a directory to store your custom kernels in: mkdir /home/ec2-user/SageMaker/kernels/

View existing kernels: conda env list

Create new kernel (replace my_new_kernel with kernel name): mamba create -q -y --prefix “/home/ec2-user/SageMaker/kernels/my_new_kernel”

Step 5: Modify a kernel

Activate a kernel (replace my_new_kernel with kernel name): conda activate /home/ec2-user/SageMaker/kernels/my-new-kernel

To create an R kernel: mamba install r-irkernel

To create a python kernel: mamba install ipykernel

Add a package to a kernel: mamba install <package name>

*note that R packages are often prefixed with r-. For example, r-tidyverse

Deactivate the kernel: conda deactivate

Step 6: Link the kernel to the conda environments

Link the kernel (replace my_new_kernel with kernel name): ln -s "/home/ec2-user/SageMaker/kernels/my-new-kernel" "/home/ec2-user/anaconda3/envs/my-new-kernel"

Step 7: Use the kernel

Your new kernel will now show up in your kernels list when creating a new notebook or modifying an existing notebook.

The kernel will persist through workspace start and stop, meaning you do not have to re-install packages. However, you will need to re-link your kernel upon workspace start. To do so, open a terminal window and re-run step 6 above.

Existing custom kernels

Rapids AI: Rapids AI is a tool that allows faster processing speed in machine learning algorithms. We have deployed a new kernel for Sagemaker notebooks specifically for Rapids AI in (conda_rapids_23.06).

SWB