google-cloud-platformgcp-ai-platform-notebook

How do I get root access to AI Platform notebook within GCP?


I am logged as user jupyter in the terminal in my GCP AI Platform notebook instance.

I want to just install a few things (cannot be installed by pip) and I am unable to ssh as root user using the gcloud command.

It would be great if someone could share a pointer of the right way to get permissions to perform these actions.

Here is a snippet of an example package installation that is causing problems -

(base)~/datascience$ sudo cp ./pip-bash-completion/pip /etc/bash_completion.d/

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for jupyter: 

I am supposed to have sudo access based on the information I see -

Zone - us-central1-b
Environment  - Python 3 (with IntelĀ® MKL)
Machine type - n1-standard-4 (4 vCPUs, 15 GB RAM)
GPU - None
Boot disk - 100 GB disk
Data disk - 100 GB disk
Backup - Not specified
Permission mode - Service account
Sudo access - Enabled

Solution

  • If you are in the Jupyter Terminal you should use sudo. Some IT admins restrict root access by using the notebook-disable-root=true metadata. You can verify this by accessing the Notebooks page in Cloud Console.

    Example of creating a new instance with root disabled:

    gcloud notebooks instances create $INSTANCE_NAME \
      --vm-image-project=deeplearning-platform-release \
      --vm-image-family=tf-latest-gpu \
      --metadata="notebook-disable-root=true,proxy-mode=mail,proxy-user-mail=user@company.com" \
      --location=us-west1-a
    

    Google Cloud AI Platform Notebooks support SSH via OSLogin. https://cloud.google.com/compute/docs/oslogin/manage-oslogin-in-an-org you need to SSH with your IAM account and then perform a sudo.