|
| 1 | +""" |
| 2 | +Copyright (C) Microsoft Corporation. All rights reserved. |
| 3 | +
|
| 4 | +Microsoft Corporation (“Microsoft”) grants you a nonexclusive, perpetual, |
| 5 | +royalty-free right to use, copy, and modify the software code provided by us |
| 6 | +("Software Code"). You may not sublicense the Software Code or any use of it |
| 7 | +(except to your affiliates and to vendors to perform work on your behalf) |
| 8 | +through distribution, network access, service agreement, lease, rental, or |
| 9 | +otherwise. This license does not purport to express any claim of ownership over |
| 10 | +data you may have shared with Microsoft in the creation of the Software Code. |
| 11 | +Unless applicable law gives you more rights, Microsoft reserves all other |
| 12 | +rights not expressly granted herein, whether by implication, estoppel or |
| 13 | +otherwise. |
| 14 | +
|
| 15 | +THE SOFTWARE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 16 | +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | +MICROSOFT OR ITS LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 19 | +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 | +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 21 | +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
| 22 | +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 23 | +ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE CODE, EVEN IF ADVISED OF THE |
| 24 | +POSSIBILITY OF SUCH DAMAGE. |
| 25 | +""" |
| 26 | + |
| 27 | +from azureml.core import Workspace |
| 28 | +from azureml.core.compute import ComputeTarget, AmlCompute |
| 29 | +from azureml.core.compute_target import ComputeTargetException |
| 30 | +from azureml.core.authentication import AzureCliAuthentication |
| 31 | +import os, json |
| 32 | + |
| 33 | +cli_auth = AzureCliAuthentication() |
| 34 | +# Get workspace |
| 35 | +ws = Workspace.from_config(auth=cli_auth) |
| 36 | + |
| 37 | +# Read the New VM Config |
| 38 | +with open("aml_config/security_config.json") as f: |
| 39 | + config = json.load(f) |
| 40 | + |
| 41 | +aml_cluster_name = config["aml_cluster_name"] |
| 42 | + |
| 43 | +# un-comment the below lines if you want to put AML Compute under Vnet. Also update /aml_config/security_config.json |
| 44 | +# vnet_resourcegroup_name = config['vnet_resourcegroup_name'] |
| 45 | +# vnet_name = config['vnet_name'] |
| 46 | +# subnet_name = config['subnet_name'] |
| 47 | + |
| 48 | +# Verify that cluster does not exist already |
| 49 | +try: |
| 50 | + cpu_cluster = ComputeTarget(workspace=ws, name=aml_cluster_name) |
| 51 | + print("Found existing cluster, use it.") |
| 52 | +except ComputeTargetException: |
| 53 | + compute_config = AmlCompute.provisioning_configuration( |
| 54 | + vm_size="STANDARD_D2_V2", |
| 55 | + vm_priority="dedicated", |
| 56 | + min_nodes=1, |
| 57 | + max_nodes=3, |
| 58 | + idle_seconds_before_scaledown="300", |
| 59 | + # #Uncomment the below lines for VNet support |
| 60 | + # vnet_resourcegroup_name=vnet_resourcegroup_name, |
| 61 | + # vnet_name=vnet_name, |
| 62 | + # subnet_name=subnet_name |
| 63 | + ) |
| 64 | + cpu_cluster = ComputeTarget.create(ws, aml_cluster_name, compute_config) |
| 65 | + |
| 66 | +cpu_cluster.wait_for_completion(show_output=True) |
0 commit comments