Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Notebook-Ausführungen mit Parametern
Mit von Vertex AI Workbench verwalteten Notebookinstanzen können Sie Parameterwerte in Ihren Notebookausführungen verwenden, um Unterschiede bei der Ausführung des Codes Ihrer Notebookdatei anzugeben.
Auf dieser Seite wird beschrieben, wie Sie Ihre Notebookdatei für die Verwendung von Parametern einrichten und Ausführungen ausführen, in denen unterschiedliche Werte für Ihre Notebookparameter angegeben sind.
Parameter zum Ausführen verschiedener Iterationen Ihrer Notebook-Datei verwenden
Sie können in Ihren Ausführungen Notebook-Parameterwerte verwenden, um denselben Notebook-Code auszuführen. Gleichzeitig werden Unterschiede wie die folgenden angegeben:
Geben Sie ein anderes Dataset oder eine andere Stichprobengröße des Datasets an.
Geben Sie verschiedene Modellkonfigurationen an, z. B. Lernrate oder Optimierungstyp.
Führen Sie verschiedene Modelle oder verschiedene Versionen desselben Modells aus.
Parameter in einer Notebookausführung verwenden
Der Vorgang zum Ausführen eines Notebooks mit Parametern umfasst zwei Hauptschritte:
Fügen Sie das parameters-Tag zu einer der Zellen der Notebookdatei hinzu.
Dies ist zwar keine technische Anforderung, aber diese Zelle enthält in der Regel Code, der Ihren Parametervariablen Werte zuweist. Dies ist jedoch keine technische Anforderung.
Wenn Sie in der Ausführung keine anderen Parameterwerte zuweisen, verwendet die Ausführung die Parameterwerte in Ihrer Notebookdatei als Standardwerte.
Erstellen Sie eine Ausführung für Ihre Notebookdatei, die neue Werte für Ihre Parameter enthält. Verwenden Sie das folgende Muster, um Ihre Parameter und ihre Werte zu formatieren: parameter1=value1,parameter2=value2. Das Format erfordert Kommas zwischen Parameter-Wert-Paaren, keine Leerzeichen und Anführungszeichen.
Wenn die Ausführung ausgeführt wird, fügt der Executor dem Notebook eine Zelle hinzu, die die Werte Ihrer Parameter direkt nach der mit parameters gekennzeichneten Zelle aktualisiert.
Hinweis
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.
Damit das Dienstkonto Ihrer Instanz die erforderlichen Berechtigungen für die Interaktion mit dem Vertex AI Workbench-Executor hat, bitten Sie Ihren Administrator, dem Dienstkonto Ihrer Instanz die folgenden IAM-Rollen für das Projekt zu erteilen:
Ihr Administrator kann dem Dienstkonto Ihrer Instanz möglicherweise auch die erforderlichen Berechtigungen über benutzerdefinierte Rollen oder andere vordefinierte Rollen erteilen.
JupyterLab öffnen
Führen Sie die folgenden Schritte aus, um JupyterLab zu öffnen und eine Notebookdatei für die Ausführung vorzubereiten.
Laden Sie eine Notebook-Datei (ipynb) hoch, öffnen Sie eine vorhandene Datei oder öffnen Sie eine neue Notebookdatei und fügen Sie den Code hinzu, den Sie im neuen Notebook ausführen möchten.
Fügen Sie den Tag parameters zur Notebookzelle hinzu
Öffnen Sie in der JupyterLab-Benutzeroberfläche Ihrer verwalteten Notebook-Instanz die Notebookdatei, die Sie ausführen möchten.
Schreiben Sie Code in eine Zelle, der Ihren Parametervariablen Werte zuweist.
Dies sind die Werte, die in der Notebookdatei verwendet werden, wenn Sie bei der Ausführung keine anderen Parameterwerte zuweisen.
Achten Sie darauf, dass die Parameterzelle noch ausgewählt ist, und klicken Sie dann in der rechten Seitenleiste auf den Attributprüfer.
Im Property-Prüftool, im Abschnitt Zellen-Tags, klicken Sie auf Tag hinzufügen, geben Sie parameters ein und drücken Sie dann Enter.
Parameterwerte für die Ausführung angeben
Klicken Sie in der JupyterLab-Benutzeroberfläche Ihrer verwalteten Notebook-Instanz auf die Schaltfläche Executor.
Geben Sie im Dialogfeld Notebooks an Executor senden im Feld Ausführungsname einen Namen für die Ausführung ein.
Wählen Sie einen Maschinentyp und einen Beschleunigertyp aus.
Wählen Sie eine Umgebung aus
Wählen Sie im Feld Typ die Option Einmalige Ausführung oder Planbasierte wiederkehrende Ausführungen aus und schließen Sie die Dialogfeld zum Planen von Ausführungen.
Wählen Sie unter Erweiterte Optionen die Region aus, in der Sie das Notebook ausführen möchten.
Wählen Sie im Feld Cloud Storage-Bucket einen verfügbaren Cloud Storage-Bucket aus oder geben Sie einen Namen für einen neuen Bucket ein. Klicken Sie dann auf Erstellen und auswählen.
Der Executor speichert Ihre Notebookausgabe in diesem Cloud Storage-Bucket.
Fügen Sie im Abschnitt Notebook-Parametrisierung und im Textfeld Eingabeparameter durch Kommas getrennte Notebookparameter hinzu. Beispiel: optimizer=SGD,learning_rate=0.01. Beim Format müssen keine Leerzeichen und keine Anführungszeichen enthalten sein.
Konfigurieren Sie den Rest der Ausführung und klicken Sie auf Senden.
[[["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-09-04 (UTC)."],[],[],null,["# Run notebook executions with parameters\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\nVertex AI Workbench managed notebooks instances\nlet you use parameter values in your notebook executions\nto specify differences in how your notebook file's code runs.\nThis page describes how to set up your notebook file to use parameters\nand how to run executions that specify different values\nfor your notebook parameters.\n\nUse parameters to run different iterations of your notebook file\n----------------------------------------------------------------\n\nYou can use notebook parameter values in your executions\nto run the same notebook code while specifying differences like the following:\n\n- Specify a different dataset to use, or a different sample size\n of the dataset.\n\n- Specify different model configurations such as learning rate or\n optimizer type.\n\n- Run different models, or run different versions of the same model.\n\nHow to use parameters in a notebook execution\n---------------------------------------------\n\nThe process for executing a notebook with parameters has two main steps:\n\n1. [Add the `parameters` tag to one of your notebook file's cells](#add-tag).\n While this isn't a technical requirement, this cell\n typically contains code that assigns values to your parameter\n variables, though this is not a technical requirement.\n If you don't assign different parameter values in your execution,\n the execution uses the parameter values in your notebook file\n as default values.\n\n2. [Create an execution for your notebook file that includes\n new values for your parameters](#provide-values). Use the\n following pattern to format your parameters and their values:\n `parameter1=value1,parameter2=value2`. The format requires commas\n between parameter-value pairs, no spaces, and no quotation marks.\n When your execution runs,\n the executor adds a cell to the notebook that updates the\n values of your parameters directly following the cell that\n is tagged `parameters`.\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 Vertex AI APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=notebooks.googleapis.com,aiplatform.googleapis.com)\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 Vertex AI APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=notebooks.googleapis.com,aiplatform.googleapis.com)\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 your instance's service account has the necessary\npermissions to interact with the Vertex AI Workbench executor,\n\nask your administrator to grant your instance's service account the\nfollowing IAM roles on the project:\n\n| **Important:** You must grant these roles to your instance's service account, *not* to your user account. Failure to grant the roles to the correct principal might result in permission errors.\n\n- Notebooks Viewer ([`roles/notebooks.viewer`](/vertex-ai/docs/workbench/instances/iam#notebooks.viewer))\n- Vertex AI User ([`roles/aiplatform.user`](/vertex-ai/docs/general/access-control#aiplatform.user))\n- Storage Admin ([`roles/storage.admin`](/storage/docs/access-control/iam-roles#standard-roles))\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nYour administrator might also be able to give your instance's service account\nthe required permissions through [custom\nroles](/iam/docs/creating-custom-roles) or other [predefined\nroles](/iam/docs/roles-overview#predefined).\n\nOpen JupyterLab\n---------------\n\nTo open JupyterLab and prepare a notebook file to run,\ncomplete the following steps.\n\n1. [Open JupyterLab](/vertex-ai/docs/workbench/managed/create-managed-notebooks-instance-console-quickstart#open-jupyterlab).\n\n2. Upload a notebook (ipynb) file, open an existing file,\n or [open a new notebook\n file](/vertex-ai/docs/workbench/managed/create-managed-notebooks-instance-console-quickstart#open-a-new-notebook-file)\n and add the code that you want to run to the new notebook.\n\n3. Make sure your notebook file's code meets the [requirements\n for using the executor](/vertex-ai/docs/workbench/managed/executor#requirements).\n\nAdd the `parameters` tag to a notebook cell\n-------------------------------------------\n\n1. In your managed notebooks instance's\n JupyterLab user interface, open the notebook file that you want to run.\n\n2. Write code in one cell that assigns values to\n your parameter variables.\n These are the values your notebook file uses if\n you don't assign different parameter values in your execution.\n\n3. Make sure your parameters cell is still selected, and then\n in the right sidebar, click the\n **Property inspector**.\n\n4. In the property inspector, in the **Cell Tags** section,\n click **Add Tag** , enter `parameters`, and then press `Enter`.\n\n | **Note:** If you tag more than one cell with `parameters`, the executor adds only one parameters cell directly following the first cell with the `parameters` tag.\n\nProvide parameter values for your execution\n-------------------------------------------\n\n1. In your managed notebooks instance's\n JupyterLab user interface, click the\n **Executor** button.\n\n2. In the **Submit notebooks to Executor** dialog,\n enter a name for your execution in the **Execution name** field.\n\n3. Select a **Machine type** and **Accelerator type**.\n\n4. Select an **Environment**.\n\n5. In the **Type** field,\n select **One-time execution** , or\n select **Schedule-based recurring executions**, and complete\n the dialog for scheduling executions.\n\n6. In **Advanced options** ,\n select the **Region** where you want to run your notebook.\n\n7. In the **Cloud Storage bucket** field,\n select an available Cloud Storage bucket or\n enter a name for a new bucket and click **Create and select**.\n The executor stores your notebook output\n in this Cloud Storage bucket.\n\n8. In the **Notebook parameterization** section\n and the **Input parameters** text box,\n add notebook parameters separated by commas, for example\n `optimizer=SGD,learning_rate=0.01`. The format requires\n that there are no spaces and no quotation marks.\n\n9. Configure the rest of your execution, and then click **Submit**.\n\nWhat's next\n-----------\n\n- Learn more about [how to run notebook code in\n the executor](/vertex-ai/docs/workbench/managed/executor)."]]