|
| 1 | +--- |
| 2 | +title: How to run Jupyter Notebooks in your workspace |
| 3 | +titleSuffix: Azure Machine Learning |
| 4 | +description: Learn how run a Jupyter Notebook without leaving your workspace in Azure Machine Learning studio. |
| 5 | +services: machine-learning |
| 6 | +author: abeomor |
| 7 | +ms.author: osomorog |
| 8 | +ms.reviewer: sgilley |
| 9 | +ms.service: machine-learning |
| 10 | +ms.subservice: core |
| 11 | +ms.topic: conceptual |
| 12 | +ms.date: 04/21/2020 |
| 13 | +# As a data scientist, I want to run Jupyter notebooks in my workspace in Azure Machine Learning studio |
| 14 | +--- |
| 15 | + |
| 16 | +# How to run Jupyter Notebooks in your workspace |
| 17 | +[!INCLUDE [applies-to-skus](../../includes/aml-applies-to-basic-enterprise-sku.md)] |
| 18 | + |
| 19 | +Learn how to run your Jupyter Notebooks directly in your workspace in Azure Machine Learning studio. While you can launch [Jupyter](https://jupyter.org/) or [JupyterLab](https://jupyterlab.readthedocs.io), you can also edit and run your notebooks without leaving the workspace. |
| 20 | + |
| 21 | +See how you can: |
| 22 | + |
| 23 | +* Create Jupyter Notebooks in your workspace |
| 24 | +* Run an experiment from a notebook |
| 25 | +* Change the notebook environment |
| 26 | +* Find details of the compute instances used to run your notebooks |
| 27 | + |
| 28 | +## Prerequisites |
| 29 | + |
| 30 | +* An Azure subscription. If you don't have an Azure subscription, create a [free account](https://aka.ms/AMLFree) before you begin. |
| 31 | +* A Machine Learning workspace. See [Create an Azure Machine Learning workspace](how-to-manage-workspace.md). |
| 32 | + |
| 33 | +## <a name="create"></a> Create notebooks |
| 34 | + |
| 35 | +In your Azure Machine Learning workspace, create a new Jupyter notebook and start working. The newly created notebook is stored in the default workspace storage. This notebook can be shared with anyone with access to the workspace. |
| 36 | + |
| 37 | +To create a new notebook: |
| 38 | + |
| 39 | +1. Open your workspace in [Azure Machine Learning studio](https://ml.azure.com). |
| 40 | +1. On the left side, select **Notebooks**. |
| 41 | +1. Select the **Create new file** icon above the list **User files** in the **My files** section. |
| 42 | + |
| 43 | + :::image type="content" source="media/how-to-run-jupyter-notebooks/create-new-file.png" alt-text="Create new file"::: |
| 44 | + |
| 45 | +1. Name the file. |
| 46 | +1. For Jupyter Notebook Files, select **Python Notebook** as the file type. |
| 47 | +1. Select a file directory. |
| 48 | +1. Select **Create**. |
| 49 | + |
| 50 | +> [!TIP] |
| 51 | +> You can create text files as well. Select **Text** as the file type and add the extension to the name (for example, myfile.py or myfile.txt) |
| 52 | +
|
| 53 | +You can also upload folders and files, including notebooks, with the tools at the top of the Notebooks page. Notebooks and most text file types display in the preview section. No preview is available for most other file types. |
| 54 | + |
| 55 | +### Clone samples |
| 56 | + |
| 57 | +Your workspace contains a **Samples** folder with notebooks designed to help you explore the SDK and serve as examples for your own machine learning projects. You can clone these notebooks into your own folder on your workspace storage container. |
| 58 | + |
| 59 | +For an example, see [Tutorial: Create your first ML experiment](tutorial-1st-experiment-sdk-setup.md#azure). |
| 60 | + |
| 61 | +### <a name="terminal"> Use files from Git and version my files |
| 62 | + |
| 63 | +You can access all Git operations by using a terminal window. All Git files and folders will be stored in your workspace file system. |
| 64 | + |
| 65 | +> [!NOTE] |
| 66 | +> Add your files and folders anywhere under the **~/cloudfiles/code/Users** folder so they will be visible in all your Jupyter environments. |
| 67 | +
|
| 68 | +To access the terminal: |
| 69 | + |
| 70 | +1. Open your workspace in [Azure Machine Learning studio](https://ml.azure.com). |
| 71 | +1. On the left side, select **Notebooks**. |
| 72 | +1. Select any notebook located in the **User files** section on the left-hand side. If you don't have any notebooks there, first [create a notebook](#create) |
| 73 | +1. Select a **Compute** target or create a new one and wait until it is running. |
| 74 | +1. Select the **Open terminal** icon. |
| 75 | + |
| 76 | + :::image type="content" source="media/how-to-run-jupyter-notebooks/open-terminal.png" alt-text="Open terminal"::: |
| 77 | + |
| 78 | +1. If you don't see the icon, select the **...** to the right of the compute target and then select **Open terminal** . |
| 79 | + |
| 80 | + :::image type="content" source="media/how-to-run-jupyter-notebooks/alt-open-terminal.png" alt-text="Open terminal from ..."::: |
| 81 | + |
| 82 | + |
| 83 | +Learn more about [cloning Git repositories into your workspace file system](concept-train-model-git-integration.md#clone-git-repositories-into-your-workspace-file-system). |
| 84 | + |
| 85 | + |
| 86 | +### Share notebooks and other files |
| 87 | + |
| 88 | +Copy and paste the URL to share a notebook or file. Only other users of the workspace will be able to access this URL. Learn more about [granting access to your workspace](how-to-assign-roles.md). |
| 89 | + |
| 90 | +## Edit a notebook |
| 91 | + |
| 92 | +To edit a notebook, open any notebook located in the **User files** section of your workspace. Click on the cell you wish to edit. |
| 93 | + |
| 94 | +When a compute instance running is running, you can also use code completion, powered by [Intellisense](https://code.visualstudio.com/docs/editor/intellisense), in any Python Notebook. |
| 95 | + |
| 96 | +You can also launch Jupyter or JupyterLab from the Notebook toolbar. Azure Machine Learning does not provide updates and fix bugs from Jupyter or JupyterLab as they are Open Source products outside of the boundary of Microsoft Support. |
| 97 | + |
| 98 | +### Useful keyboard shortcuts |
| 99 | + |
| 100 | +|Keyboard |Action | |
| 101 | +|---------|---------| |
| 102 | +|Shift+Enter | Run a cell | |
| 103 | +|Ctrl+M(Windows) | Enable/disable tab trapping in notebook. | |
| 104 | +|Ctrl+Shift+M(Mac & Linux) | Enable/disable tab trapping in notebook. | |
| 105 | +|Tab (when tab trap enabled) | Add a '\t' character (indent) |
| 106 | +|Tab (when tab trap disabled) | Change focus to next focusable item (delete cell button, run button, etc.) |
| 107 | + |
| 108 | +## Delete a notebook |
| 109 | + |
| 110 | +You *can't* delete the **Samples** notebooks. These notebooks are part of the studio and are updated each time a new SDK is published. |
| 111 | + |
| 112 | +You *can* delete **User files** notebooks in any of these ways: |
| 113 | + |
| 114 | +* In the studio, select the **...** at the end of a folder or file. Make sure to use a supported browser (Microsoft Edge, Chrome, or Firefox). |
| 115 | +* From any Notebook toolbar, select [**Open terminal**](#terminal) to access the terminal window for the compute instance. |
| 116 | +* In either Jupyter or JupyterLab with their tools. |
| 117 | + |
| 118 | +## Run an experiment |
| 119 | + |
| 120 | +To run an experiment from a Notebook, you first connect to a running [compute instance](concept-compute-instance.md). If you don't have a compute instance, use these steps to create one: |
| 121 | + |
| 122 | +1. Select **+** in the Notebook toolbar. |
| 123 | +2. Name the Compute and choose a **Virtual Machine Size**. |
| 124 | +3. Select **Create**. |
| 125 | +4. The compute instance is connected to the Notebook automatically and you can now run your cells. |
| 126 | + |
| 127 | +Only you can see and use the compute instances you create. Your **User files** are stored separately from the VM and are shared among all compute instances in the workspace. |
| 128 | + |
| 129 | +### View logs and output |
| 130 | + |
| 131 | +Use [Notebook widgets](https://docs.microsoft.com/python/api/azureml-widgets/azureml.widgets?view=azure-ml-py) to view the progress of the run and logs. A widget is asynchronous and provides updates until training finishes. Azure Machine Learning widgets are also supported in Jupyter and JupterLab. |
| 132 | + |
| 133 | +## Change the notebook environment |
| 134 | + |
| 135 | +The Notebook toolbar allows you to change the environment on which your Notebook runs. |
| 136 | + |
| 137 | +These actions will not change the notebook state or the values of any variables in the notebook: |
| 138 | + |
| 139 | +|Action |Result | |
| 140 | +|---------|---------| --------| |
| 141 | +|Stop the kernel | Stops any running cell. Running a cell will automatically restart the kernel. | |
| 142 | +|Navigate to another workspace section | Running cells are stopped. | |
| 143 | + |
| 144 | +These actions will reset the notebook state and will reset all variables in the notebook. |
| 145 | + |
| 146 | +|Action |Result | |
| 147 | +|---------|---------| --------| |
| 148 | +| Change the kernel | Notebook uses new kernel | |
| 149 | +| Switch compute | Notebook automatically uses the new compute. | |
| 150 | +| Reset compute | Starts again when you try to run a cell | |
| 151 | +| Stop compute | No cells will run | |
| 152 | +| Open notebook in Jupyter or JupyterLab | Notebook opened in a new tab. | |
| 153 | + |
| 154 | +### Add new kernels |
| 155 | + |
| 156 | +The Notebook will automatically find all Jupyter kernels installed on the connected compute instance. To add a kernel to the compute instance: |
| 157 | + |
| 158 | +1. Select [**Open terminal**](#terminal) in the Notebook toolbar. |
| 159 | +1. Use the terminal window to create a new environment. |
| 160 | +1. Activate the environment. For example, after creating `newenv`: |
| 161 | + |
| 162 | + ```shell |
| 163 | + source activate newenv |
| 164 | + python -m ipykernel install --user --name newenv --display-name "Python (newenv)" |
| 165 | + ``` |
| 166 | + |
| 167 | +Any of the [available Jupyter Kernels](https://github.com/jupyter/jupyter/wiki/Jupyter-kernels) can be installed. |
| 168 | + |
| 169 | +### Status indicators |
| 170 | + |
| 171 | +An indicator next to the **Compute** dropdown shows its status. The status is also shown in the dropdown itself. |
| 172 | + |
| 173 | +|Color |Compute status | |
| 174 | +|---------|---------| |
| 175 | +| Green | Compute running | |
| 176 | +| Red |Compute failed | |
| 177 | +| Black | Compute stopped | |
| 178 | +| Light Blue |Compute creating, starting, restarting, setting Up | |
| 179 | +| Gray |Compute deleting, stopping | |
| 180 | + |
| 181 | +An indicator next to the **Kernel** dropdown shows its status. |
| 182 | + |
| 183 | +|Color |Kernel status | |
| 184 | +|---------|---------| |
| 185 | +| Green |Kernel connected, idle, busy| |
| 186 | +| Gray |Kernel not connected | |
| 187 | + |
| 188 | +## Find compute details |
| 189 | + |
| 190 | +Find details about your compute instances on the **Compute** page in [studio](https://ml.azure.com). |
| 191 | + |
| 192 | +## Next steps |
| 193 | + |
| 194 | +* [Run your first experiment](tutorial-1st-experiment-sdk-train.md) |
| 195 | +* [Backup your file storage with snapshots](../storage/files/storage-snapshots-files.md) |
0 commit comments