Skip to content

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.


In your Amazon SageMaker environment:

  1. In the left pane, under Notebook, select Lifecycle configurations.
  2. Click Create configuration.
  3. Enter a name for your lifecycle configuration (you'll need it in step 7).
  4. Modify the Create notebook script to run it once at the creation of your SageMaker Notebook instance.
  5. Copy-paste the following to the Create notebook script:


    In the PARAMETERS section, specify in which environments you want to install the Neptune client library (neptune).

    set -e
    sudo -u ec2-user -i <<'EOF'
    # 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
    # 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
  6. In the left pane, select Notebook instances and click Create notebook instance.

  7. Type in an instance name and click Additional configuration to add the lifecycle configuration you just created.
  8. To start your instance, click Create notebook instance.


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.