首页 > 解决方案 > 如何在 GCP 中获得对 AI Platform notebook 的 root 访问权限?

问题描述

jupyter在 GCP AI Platform 笔记本实例的终端中以用户身份登录。

我只想安装一些东西(不能通过 pip 安装)并且我无法使用 gcloud 命令以 root 用户身份进行 ssh。

如果有人可以分享正确方法的指针来获得执行这些操作的权限,那就太好了。

这是导致问题的示例包安装的片段 -

(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: 

sudo根据我看到的信息,我应该可以访问 -

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

标签: google-cloud-platformgcp-ai-platform-notebook

解决方案


如果你在 Jupyter 终端,你应该使用sudo. 一些 IT 管理员使用notebook-disable-root=true元数据来限制 root 访问。您可以通过访问 Cloud Console 中的笔记本页面来验证这一点。

创建禁用 root 的新实例的示例:

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 通过 OSLogin 支持 SSH。https://cloud.google.com/compute/docs/oslogin/manage-oslogin-in-an-org 您需要使用您的 IAM 帐户进行 SSH,然后执行 sudo。


推荐阅读