> For the complete documentation index, see [llms.txt](https://pic-sure.gitbook.io/service-workbench/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pic-sure.gitbook.io/service-workbench/general-user-guide/research-workspaces/using-custom-jupyter-notebook-kernels.md).

# Using custom Jupyter Notebook kernels

## Creating a custom kernel

<details>

<summary>Step 1: Create a SageMaker workspace using one of the kernels workspace types</summary>

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".&#x20;

<img src="/files/uYEOwyW1LmsFavVMzaOq" alt="" data-size="original">

</details>

<details>

<summary>Step 2: Open a Terminal window</summary>

![](/files/ZU04S5VxNAYZUxyFC3OS)

</details>

<details>

<summary>Step 3: Log in as an administrator by running <code>sudo su ec2-user</code></summary>

</details>

<details>

<summary>Step 4: Create a new kernel</summary>

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”`

</details>

<details>

<summary>Step 5: Modify a kernel</summary>

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`

</details>

<details>

<summary>Step 6: Link the kernel to the conda environments</summary>

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"`

</details>

<details>

<summary>Step 7: Use the kernel</summary>

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

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.&#x20;

</details>

## 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 [SWB](https://swb.aim-ahead.host/) (conda\_rapids\_23.06).&#x20;
