Search code examples
google-cloud-platformjupyter-labgoogle-cloud-vertex-aigcp-ai-platform-notebook

Modifying default kernel name in a Vertex AI User Managed Notebook instance


TL;DR

How do you change the kernel display name of the default base conda environment in a Vertex AI User Managed Notebook instance using a Dockerfile or post-startup script?

Details

In a Vertex AI User Managed Notebook instance, the Launcher shows the default "base" conda environment kernel as "Python 3 (ipykernel)". I would like to change this display name. There are various threads on how to change or disable/hide this kernel within Jupyter Notebooks (here, here, here, here). However, I am not having much luck in the context of Vertex AI User Managed Notebooks.

Could someone please describe how to do this, preferably from within a Dockerfile (which I use to create an image from which the Notebook instance is built), or if that isn't possible, from a post-startup script applied during Notebook instance creation? In the end, I would like to be able to open a brand new Notebook instance and see that the base environment's exposed kernel has a name of my choosing.


Solution

  • Adding the following lines to the Docker file used to create an image from which a Vertex AI User Managed Notebook is generated, properly alters the display name of the default kernel tied to the base conda environment. The environment's actual name remains the same, as you can't change the name of the base environment per documentation. The second line may or may not be necessary depending on your set-up.

    RUN sed -i 's/Python 3 (ipykernel)/someNewEnvName/' /opt/conda/share/jupyter/kernels/python3/kernel.json
    RUN rm /root/.local/share/jupyter/kernels/base/kernel.json