224 lines
8.0 KiB
Plaintext
224 lines
8.0 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
|
|
"\n",
|
|
"Licensed under the MIT License."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# 00. Installation and configuration\n",
|
|
"\n",
|
|
"## Prerequisites:\n",
|
|
"\n",
|
|
"### 1. Install Azure ML SDK\n",
|
|
"Follow [SDK installation instructions](https://docs.microsoft.com/azure/machine-learning/service/how-to-configure-environment).\n",
|
|
"\n",
|
|
"### 2. Install some additional packages\n",
|
|
"This Notebook requires some additional libraries. In the conda environment, run below commands: \n",
|
|
"```shell\n",
|
|
"(myenv) $ conda install -y matplotlib tqdm scikit-learn\n",
|
|
"```\n",
|
|
"\n",
|
|
"### 3. Make sure your subscription is registered to use ACI.\n",
|
|
"This Notebook makes use of Azure Container Instance (ACI). You need to ensure your subscription has been registered to use ACI in order be able to deploy a dev/test web service.\n",
|
|
"```shell\n",
|
|
"# check to see if ACI is already registered\n",
|
|
"(myenv) $ az provider show -n Microsoft.ContainerInstance -o table\n",
|
|
"\n",
|
|
"# if ACI is not registered, run this command.\n",
|
|
"# note you need to be the subscription owner in order to execute this command successfully.\n",
|
|
"(myenv) $ az provider register -n Microsoft.ContainerInstance\n",
|
|
"```\n",
|
|
"\n",
|
|
"In this example you will optionally create an Azure Machine Learning Workspace and initialize your notebook directory to easily use this workspace. Typically you will only need to run this once per notebook directory, and all other notebooks in this directory or any sub-directories will automatically use the settings you indicate here.\n",
|
|
"\n",
|
|
"This notebook also contains optional cells to install and update the require Azure Machine Learning libraries."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"tags": [
|
|
"install"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Check core SDK version number for debugging purposes\n",
|
|
"import azureml.core\n",
|
|
"\n",
|
|
"print(\"SDK Version:\", azureml.core.VERSION)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Initialize an Azure ML Workspace\n",
|
|
"### What is an Azure ML Workspace and why do I need one?\n",
|
|
"\n",
|
|
"An AML Workspace is an Azure resource that organaizes and coordinates the actions of many other Azure resources to assist in executing and sharing machine learning workflows. In particular, an AML Workspace coordinates storage, databases, and compute resources providing added functionality for machine learning experimentation, operationalization, and the monitoring of operationalized models.\n",
|
|
"\n",
|
|
"### What do I need\n",
|
|
"\n",
|
|
"In order to use an AML Workspace, first you need access to an Azure Subscription. You can [create your own](https://azure.microsoft.com/en-us/free/) or get your existing subscription information from the [Azure portal](https://portal.azure.com). Inside your subscription, you will need access to a _resource group_, which organizes Azure resources and provides a default region for the resources in a group. You can see what resource groups to which you have access, or create a new one in the [Azure portal](https://portal.azure.com)\n",
|
|
"\n",
|
|
"You can also easily create a new resource group using azure-cli.\n",
|
|
"\n",
|
|
"```sh\n",
|
|
"(myenv) $ az group create -n my_resource_group -l eastus2\n",
|
|
"```\n",
|
|
"\n",
|
|
"To create or access an Azure ML Workspace, you will need to import the AML library and the following information:\n",
|
|
"* A name for your workspace\n",
|
|
"* Your subscription id\n",
|
|
"* The resource group name\n",
|
|
"\n",
|
|
"**Note**: As with other Azure services, there are limits on certain resources (for eg. BatchAI cluster size) associated with the Azure Machine Learning service. Please read [this article](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-manage-quotas) on the default limits and how to request more quota."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Supported Azure Regions\n",
|
|
"Please specify the Azure subscription Id, resource group name, workspace name, and the region in which you want to create the workspace, for example \"eastus2\". "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import os\n",
|
|
"\n",
|
|
"subscription_id = os.environ.get(\"SUBSCRIPTION_ID\", \"<my-subscription-id>\")\n",
|
|
"resource_group = os.environ.get(\"RESOURCE_GROUP\", \"<my-rg>\")\n",
|
|
"workspace_name = os.environ.get(\"WORKSPACE_NAME\", \"<my-workspace>\")\n",
|
|
"workspace_region = os.environ.get(\"WORKSPACE_REGION\", \"eastus2\") # or eastus2euap"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Creating a workspace\n",
|
|
"If you already have access to an AML Workspace you want to use, you can skip this cell. Otherwise, this cell will create an AML workspace for you in a subscription provided you have the correct permissions.\n",
|
|
"\n",
|
|
"This will fail when:\n",
|
|
"1. You do not have permission to create a workspace in the resource group\n",
|
|
"2. You are not a subscription owner or contributor and no Azure ML workspaces have ever been created in this subscription\n",
|
|
"\n",
|
|
"If workspace creation fails, please work with your IT admin to provide you with the appropriate permissions or to provision the required resources."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"tags": [
|
|
"create workspace"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# import the Workspace class and check the azureml SDK version\n",
|
|
"from azureml.core import Workspace\n",
|
|
"\n",
|
|
"ws = Workspace.create(name = workspace_name,\n",
|
|
" subscription_id = subscription_id,\n",
|
|
" resource_group = resource_group, \n",
|
|
" location = workspace_region,\n",
|
|
" exist_ok = True)\n",
|
|
"ws.get_details()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Configuring your local environment\n",
|
|
"You can validate that you have access to the specified workspace and write a configuration file to the default configuration location, `./aml_config/config.json`."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"tags": [
|
|
"create workspace"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"ws = Workspace(workspace_name = workspace_name,\n",
|
|
" subscription_id = subscription_id,\n",
|
|
" resource_group = resource_group)\n",
|
|
"\n",
|
|
"# persist the subscription id, resource group name, and workspace name in aml_config/config.json.\n",
|
|
"ws.write_config()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"You can then load the workspace from this config file from any notebook in the current directory."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"tags": [
|
|
"create workspace"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# load workspace configuratio from ./aml_config/config.json file.\n",
|
|
"my_workspace = Workspace.from_config()\n",
|
|
"my_workspace.get_details()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Success!\n",
|
|
"Great, you are ready to move on to the rest of the sample notebooks."
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3.6",
|
|
"language": "python",
|
|
"name": "python36"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.6.4"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|