Enable Neptune in Amazon SageMaker notebook configuration#
This guide shows how to enable Neptune in your Amazon SageMaker notebooks.
It involves installing the Neptune client library as well as the neptune-notebooks extension, so that your notebooks are automatically versioned in Neptune.
Setup#
In your Amazon SageMaker environment:
- In the left pane, under Notebook, select Lifecycle configurations.
- Click Create configuration.
- Enter a name for your lifecycle configuration (you'll need it in step 7).
- Modify the Create notebook script to run it once at the creation of your SageMaker Notebook instance.
-
Copy-paste the following to the Create notebook script:
Note
In the
PARAMETERS
section, specify in which environments you want to install the Neptune client library (neptune).#!/bin/bash set -e sudo -u ec2-user -i <<'EOF' # PARAMETERS ENVS=( python3 pytorch_p36 ) # Install Neptune client library for env in $ENVS; do source /home/ec2-user/anaconda3/bin/activate $env pip install neptune source /home/ec2-user/anaconda3/bin/deactivate done # Install Jupyter extension source /home/ec2-user/anaconda3/bin/activate JupyterSystemEnv pip install neptune-notebooks jupyter nbextension enable --py neptune-notebooks --sys-prefix jupyter labextension install neptune-notebooks source /home/ec2-user/anaconda3/bin/deactivate EOF
-
In the left pane, select Notebook instances and click Create notebook instance.
- Type in an instance name and click Additional configuration to add the lifecycle configuration you just created.
- To start your instance, click Create notebook instance.
Success
If everything was set up correctly, the status of your Amazon SageMaker instance should be "InService".
You can open a Jupyter Notebook or JupyterLab with Neptune notebook versioning enabled.
Next steps#
To make use of Neptune logging, you can import and use Neptune just like you normally would in your Python code.
For instructions, the Using Neptune tab is a good place to start.