Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Aggiungere un ambiente conda
Questa pagina descrive come aggiungere un ambiente conda all'istanza Vertex AI Workbench.
Panoramica
Quando aggiungi un ambiente conda alla tua istanza Vertex AI Workbench, viene visualizzato come kernel nell'interfaccia JupyterLab dell'istanza.
Puoi aggiungere un ambiente conda all'istanza Vertex AI Workbench per utilizzare i kernel non disponibili nelle istanze Vertex AI Workbench.
Ad esempio, puoi aggiungere ambienti conda per R e Apache Beam. In alternativa, puoi aggiungere ambienti conda per versioni precedenti specifiche dei framework disponibili, come TensorFlow, PyTorch o Python.
CONDA_ENVIRONMENT_NAME: il nome scelto per l'ambiente
PACKAGE: il pacchetto che vuoi installare
KERNEL_DISPLAY_NAME: il nome visualizzato per il riquadro del kernel nell'interfaccia di JupyterLab
È possibile creare un kernel predefinito durante l'installazione in un determinato ambiente conda. Puoi rimuovere il kernel predefinito con il seguente comando:
Il kernel è elencato tra gli altri nella finestra del Lanciatore.
Per impostazione predefinita, conda potrebbe utilizzare i pacchetti pip nella cartella pip del sistema (ad esempio /usr/bin/pip). L'esecuzione di conda install pip garantisce che la configurazione utilizzi un pip locale per l'ambiente.
Installazione di esempio: R Essentials
L'esempio seguente installa R Essentials in un ambiente conda denominato r.
conda create -n r
conda activate r
conda install -c r r-essentials
Esempio di installazione: pacchetto pip
L'esempio seguente installa i pacchetti pip da un file requirements.txt.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[],[],null,["# Add a conda environment to a Vertex AI Workbench instance\n\nAdd a conda environment\n=======================\n\nThis page describes how to add a conda environment to your\nVertex AI Workbench instance.\n\nOverview\n--------\n\nWhen you add a conda environment to\nyour Vertex AI Workbench instance, it appears as a\n[kernel](https://jupyterlab.readthedocs.io/en/stable/user/documents_kernels.html)\nin your instance's JupyterLab interface.\n\nYou might add a conda environment to your Vertex AI Workbench instance\nto use kernels that aren't available in Vertex AI Workbench instances.\nFor example, you can add conda environments for R and Apache Beam. Or you\ncan add conda environments for specific older versions of the available\nframeworks, such as TensorFlow, PyTorch, or Python.\n\nBefore you begin\n----------------\n\nIf you haven't already,\n[create\na Vertex AI Workbench instance](/vertex-ai/docs/workbench/instances/create-console-quickstart).\n\nOpen JupyterLab\n---------------\n\n1. In the Google Cloud console, go to the **Instances** page.\n\n [Go to Instances](https://console.cloud.google.com/vertex-ai/workbench/instances)\n2. Next to your Vertex AI Workbench instance's name,\n click **Open JupyterLab**.\n\n Your Vertex AI Workbench instance opens JupyterLab.\n\nAdd a conda environment\n-----------------------\n\nYou can add a conda environment by entering commands in your instance's\nJupyterLab terminal.\n\n1. In JupyterLab,\n select **File \\\u003e New \\\u003e Terminal**.\n\n2. In the **Terminal** window, enter the following commands:\n\n ```genshi\n # Creates a conda environment.\n conda create -n CONDA_ENVIRONMENT_NAME -y\n conda activate CONDA_ENVIRONMENT_NAME\n\n # Install packages using a pip local to the conda environment.\n conda install pip\n pip install PACKAGE\n\n # Adds the conda kernel.\n DL_ANACONDA_ENV_HOME=\"${DL_ANACONDA_HOME}/envs/CONDA_ENVIRONMENT_NAME\"\n python -m ipykernel install --prefix \"${DL_ANACONDA_ENV_HOME}\" --name CONDA_ENVIRONMENT_NAME --display-name KERNEL_DISPLAY_NAME\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eCONDA_ENVIRONMENT_NAME\u003c/var\u003e: your choice of name for the environment\n - \u003cvar translate=\"no\"\u003ePACKAGE\u003c/var\u003e: the package that you want to install\n - \u003cvar translate=\"no\"\u003eKERNEL_DISPLAY_NAME\u003c/var\u003e: the display name for the tile of the kernel in the JupyterLab interface\n3. A default kernel can be created when installing to a given\n conda environment. You can remove the default kernel with the\n following command:\n\n ```scdoc\n rm -rf \"/opt/micromamba/envs/CONDA_ENVIRONMENT_NAME/share/jupyter/kernels/python3\n ```\n4. To see your new kernel, do the following:\n\n 1. Refresh the page.\n\n 2. Select **File \\\u003e New Launcher**.\n\n The kernel is listed among the others in the **Launcher** window.\n\nBy default, conda might use pip packages in the system `pip` folder\n(for example, `/usr/bin/pip`). Running `conda install pip` ensures that\nthe setup uses a pip local to the environment.\n\nExample installation: R Essentials\n----------------------------------\n\nThe following example installs R Essentials in a conda environment named `r`. \n\n```text\nconda create -n r\nconda activate r\nconda install -c r r-essentials\n```\n\nExample installation: pip package\n---------------------------------\n\nThe following example installs pip packages from a `requirements.txt` file. \n\n```genshi\nconda create -n myenv\nconda activate myenv\nconda install pip\npip install -r requirements.txt\nDL_ANACONDA_ENV_HOME=\"${DL_ANACONDA_HOME}/envs/myenv\"\npython -m ipykernel install --prefix \"${DL_ANACONDA_ENV_HOME}\" --name myenv --display-name myenv\n```\n\nTroubleshoot\n------------\n\nTo diagnose and resolve issues related to adding a conda environment,\nsee [Troubleshooting\nVertex AI Workbench](/vertex-ai/docs/general/troubleshooting-workbench#pip-packages-missing-instances).\n\nWhat's next\n-----------\n\n- Learn more about [conda](https://docs.conda.io/en/latest/).\n\n- To modify your conda environment, see [Manage your conda\n environment](/vertex-ai/docs/workbench/instances/manage-environment)."]]