Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Verwaltete Notebookinstanz in einem Dataproc-Cluster ausführen
Auf dieser Seite wird beschrieben, wie Sie die Notebookdatei einer verwalteten Notebookinstanz in einem Dataproc-Cluster ausführen.
Hinweise
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
Bitten Sie Ihren Administrator, dem Dienstkonto die folgenden IAM-Rollen zu gewähren, damit das Dienstkonto die erforderlichen Berechtigungen zum Ausführen einer Notebook-Datei auf einem serverlosen Dataproc-Cluster hat:
Diese vordefinierten Rollen enthalten die Berechtigungen, die zum Ausführen einer Notebook-Datei auf einem Dataproc-Cluster erforderlich sind. Erweitern Sie den Abschnitt Erforderliche Berechtigungen, um die erforderlichen Berechtigungen anzuzeigen:
Erforderliche Berechtigungen
Die folgenden Berechtigungen sind erforderlich, um eine Notebook-Datei auf einem Dataproc-Servercluster auszuführen:
Der Cluster muss sich in derselben Region wie die verwaltete Notebookinstanz befinden.
Geben Sie zum Erstellen Ihres Dataproc-Clusters den folgenden Befehl entweder in Cloud Shell oder einer Umgebung ein, in der das Google Cloud CLI installiert ist.
Klicken Sie neben dem Namen der verwalteten Notebookinstanz auf JupyterLab öffnen.
Notebookdatei in Ihrem Dataproc-Cluster ausführen
Sie können eine Notebookdatei in Ihrem Dataproc-Cluster über jede verwaltete Notebookinstanz im selben Projekt und in derselben Region ausführen.
Neue Notebookdatei ausführen
Wählen Sie in der JupyterLab-Oberfläche Ihrer verwalteten Notebookinstanz Folgendes aus: Datei>Neu >Notebook.
Die verfügbaren Kernel Ihres Dataproc-Clusters werden im Menü Kernel auswählen angezeigt. Wählen Sie den gewünschten Kernel aus und klicken Sie auf Auswählen.
Ihre neue Notebookdatei wird geöffnet.
Fügen Sie der neuen Notebookdatei Code hinzu und führen Sie den Code aus.
Informationen zum Ändern des Kernels, den Sie nach dem Erstellen Ihrer Notebookdatei verwenden möchten, finden Sie im folgenden Abschnitt.
Vorhandene Notebookdatei ausführen
Klicken Sie in der JupyterLab-Oberfläche Ihrer verwalteten Notebook-Instanz auf die Schaltfläche folderDateibrowser, wechseln Sie zur Notebookdatei, die Sie ausführen möchten, und öffnen Sie sie.
Klicken Sie zum Öffnen des Dialogfelds Kernel auswählen auf den Kernelnamen Ihrer Notebookdatei, z. B. Python (lokal).
Wählen Sie einen Kernel-Namen aus, der Ihren Clusternamen am Ende enthält, um einen Kernel aus Ihrem Dataproc-Cluster auszuwählen.
Ein PySpark-Kernel in einem Dataproc-Cluster mit dem Namen mycluster heißt beispielsweise PySpark on mycluster.
Klicken Sie auf Auswählen, um das Dialogfeld zu schließen.
Sie können den Code Ihrer Notebookdatei jetzt im Dataproc-Cluster ausführen.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-18 (UTC)."],[],[],null,["# Run a managed notebooks instance on a Dataproc cluster\n======================================================\n\n\n| Vertex AI Workbench managed notebooks is\n| [deprecated](/vertex-ai/docs/deprecations). On\n| April 14, 2025, support for\n| managed notebooks will end and the ability to create managed notebooks instances\n| will be removed. Existing instances will continue to function\n| but patches, updates, and upgrades won't be available. To continue using\n| Vertex AI Workbench, we recommend that you\n| [migrate\n| your managed notebooks instances to Vertex AI Workbench instances](/vertex-ai/docs/workbench/managed/migrate-to-instances).\n\n\u003cbr /\u003e\n\nThis page shows you how to run a managed notebooks instance's\nnotebook file on a Dataproc cluster.\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Notebooks and Dataproc APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=notebooks.googleapis.com,dataproc)\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Notebooks and Dataproc APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=notebooks.googleapis.com,dataproc)\n\n1. If you haven't already, [create\n a managed notebooks instance](/vertex-ai/docs/workbench/managed/create-instance#create).\n\n### Required roles\n\n\nTo ensure that the service account has the necessary\npermissions to run a notebook file on a Dataproc Serverless cluster,\n\nask your administrator to grant the service account the\nfollowing IAM roles:\n\n| **Important:** You must grant these roles to the service account, *not* to your user account. Failure to grant the roles to the correct principal might result in permission errors.\n\n- [Dataproc Worker](/iam/docs/roles-permissions/dataproc#dataproc.worker) (`roles/dataproc.worker`) on your project\n- [Dataproc Editor](/iam/docs/roles-permissions/dataproc#dataproc.editor) (`roles/dataproc.editor`) on the cluster for the `dataproc.clusters.use` permission\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nThese predefined roles contain\n\nthe permissions required to run a notebook file on a Dataproc Serverless cluster. To see the exact permissions that are\nrequired, expand the **Required permissions** section:\n\n\n#### Required permissions\n\nThe following permissions are required to run a notebook file on a Dataproc Serverless cluster:\n\n- ` dataproc.agents.create `\n- ` dataproc.agents.delete `\n- ` dataproc.agents.get `\n- ` dataproc.agents.update `\n- ` dataproc.tasks.lease `\n- ` dataproc.tasks.listInvalidatedLeases `\n- ` dataproc.tasks.reportStatus `\n- ` dataproc.clusters.use`\n\n\nYour administrator might also be able to give the service account\nthese permissions\nwith [custom roles](/iam/docs/creating-custom-roles) or\nother [predefined roles](/iam/docs/roles-overview#predefined).\n\nCreate a Dataproc cluster\n-------------------------\n\nTo run a managed notebooks instance's notebook file\nin a Dataproc cluster, your cluster must meet the following\ncriteria:\n\n- The cluster's component gateway must be enabled.\n\n- The cluster must have\n the [Jupyter component](/dataproc/docs/concepts/components/jupyter).\n\n- The cluster must be in the same region as\n your managed notebooks instance.\n\nTo create your Dataproc cluster,\nenter the following command in either\n[Cloud Shell](https://console.cloud.google.com?cloudshell=true) or another\nenvironment where the [Google Cloud CLI](/sdk/docs) is installed. \n\n```bash\ngcloud dataproc clusters create CLUSTER_NAME\\\n --region=REGION \\\n --enable-component-gateway \\\n --optional-components=JUPYTER\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the Google Cloud location of\n your managed notebooks instance\n\n- \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: the name of your new\n cluster\n\nAfter a few minutes, your Dataproc cluster\nis available for use. [Learn more about creating Dataproc\nclusters](/dataproc/docs/guides/create-cluster).\n\nOpen JupyterLab\n---------------\n\n1. If you haven't already,\n [create\n a managed notebooks instance](/vertex-ai/docs/workbench/managed/create-instance#create) in the same region\n where your Dataproc cluster is.\n\n2. In the Google Cloud console, go to the **Managed notebooks** page.\n\n [Go to Managed notebooks](https://console.cloud.google.com/vertex-ai/workbench/managed)\n3. Next to your managed notebooks instance's name,\n click **Open JupyterLab**.\n\nRun a notebook file in your Dataproc cluster\n--------------------------------------------\n\nYou can run a notebook file in your Dataproc cluster\nfrom any managed notebooks instance in the same project and\nregion.\n\n### Run a new notebook file\n\n1. In your managed notebooks instance's JupyterLab interface,\n select **File \\\u003e\n New \\\u003e Notebook**.\n\n2. Your Dataproc cluster's available kernels appear in\n the **Select kernel** menu. Select the kernel that you want to use,\n and then click **Select**.\n\n Your new notebook file opens.\n3. Add code to your new notebook file, and run the code.\n\nTo change the kernel that you want to use\nafter you've created your notebook file, see the following section.\n\n### Run an existing notebook file\n\n1. In your managed notebooks instance's JupyterLab interface,\n click the\n folder **File Browser** button,\n navigate to the notebook file that you want to run, and open it.\n\n2. To open the **Select kernel** dialog, click the kernel name of your notebook\n file, for example: **Python (Local)**.\n\n3. To select a kernel from your Dataproc cluster,\n select a kernel name that includes your cluster name at the end of it.\n For example, a PySpark kernel on a Dataproc cluster\n named `mycluster` is named **PySpark on mycluster**.\n\n4. Click **Select** to close the dialog.\n\n You can now run your notebook file's code\n on the Dataproc cluster.\n\nWhat's next\n-----------\n\n- Learn more about [Dataproc](/dataproc/docs/concepts/overview)."]]