Exemplo n.º 1
0
def prepare_remote_compute(ws):
    compute_name = os.environ.get("AML_COMPUTE_CLUSTER_NAME", "cpucluster")
    compute_min_nodes = os.environ.get("AML_COMPUTE_CLUSTER_MIN_NODES", 1)
    compute_max_nodes = os.environ.get("AML_COMPUTE_CLUSTER_MAX_NODES", 4)

    # This example uses CPU VM. For using GPU VM, set SKU to STANDARD_NC6
    vm_size = os.environ.get("AML_COMPUTE_CLUSTER_SKU", "STANDARD_D2_V2")

    if compute_name in ws.compute_targets:
        compute_target = ws.compute_targets[compute_name]
        if compute_target and type(compute_target) is AmlCompute:
            print('found compute target. Using it. ' + compute_name)
    else:
        print('creating a new compute target...')
        provisioning_config = AmlCompute.provisioning_configuration(
            vm_size=vm_size,
            min_nodes=compute_min_nodes,
            max_nodes=compute_max_nodes)
        # create the cluster
        compute_target = ComputeTarget.create(ws, compute_name,
                                              provisioning_config)

        # can poll for a minimum number of nodes and for a specific timeout.
        # if no min node count is provided it will use the scale settings for the cluster
        compute_target.wait_for_completion(show_output=True,
                                           min_node_count=None,
                                           timeout_in_minutes=20)

        # For a more detailed view of current AmlCompute status, use get_status()
        print(compute_target.get_status().serialize())

    return compute_target
def main(name, vm_size, nodes):
    ws = Workspace.from_config()

    try:
        compute_cluster = ComputeTarget(ws, name)
    except:
        compute_config = AmlCompute.provisioning_configuration(vm_size=vm_size,
                                                               min_nodes=1,
                                                               max_nodes=nodes)

        compute_cluster = ComputeTarget.create(ws, name, compute_config)
        compute_cluster.wait_for_completion(show_output=True)
Exemplo n.º 3
0
def prepare_remote_compute(ws,
                           compute_name,
                           compute_min_nodes=0,
                           compute_max_nodes=4,
                           compute_vm_size='STANDARD_D2_V2'):
    """
    :param ws: azureml Workspace instance
    :param compute_name: String with name for compute target
    :param compute_min_nodes: minimum number of nodes
    :param compute_max_nodes: maximum number of nodes
    :param compute_vm_size: vm size for compute target
    :return:
    """

    if compute_name in ws.compute_targets:
        compute_target = ws.compute_targets[compute_name]
        if compute_target and type(compute_target) is AmlCompute:
            print('Found compute target: ' + compute_name + ' of size: ' +
                  compute_target.vm_size + '. Using it. ')
            print(
                'For a different size create a new target with different name!'
            )
            # TODO: Handle case if compute_name exists, but is not active!
    else:
        print('creating a new compute target...')
        provisioning_config = AmlCompute.provisioning_configuration(
            vm_size=compute_vm_size,
            min_nodes=compute_min_nodes,
            max_nodes=compute_max_nodes)
        # create the cluster
        compute_target = ComputeTarget.create(ws, compute_name,
                                              provisioning_config)

        # can poll for a minimum number of nodes and for a specific timeout.
        # if no min node count is provided it will use the scale settings for the cluster
        compute_target.wait_for_completion(show_output=True,
                                           min_node_count=None,
                                           timeout_in_minutes=20)

        # For a more detailed view of current AmlCompute status, use get_status()
        print(compute_target.get_status().serialize())

    return compute_target
Exemplo n.º 4
0
    variables[d['name']] = d['value']

# Check if compute cluster exists. If not, create one.
try:
    compute_target = ComputeTarget(aml_workspace,
                                   variables["AML_COMPUTE_CLUSTER_CPU_SKU"])
    print('Found existing cluster, use it.')
except ComputeTargetException:
    compute_config = AmlCompute.provisioning_configuration(
        vm_size=variables['AML_COMPUTE_CLUSTER_SIZE'],
        vm_priority=variables['AML_CLUSTER_PRIORITY'],
        min_nodes=variables['AML_CLUSTER_MIN_NODES'],
        max_nodes=variables['AML_CLUSTER_MAX_NODES'],
        idle_seconds_before_scaledown="300")
    cpu_cluster = ComputeTarget.create(
        aml_workspace, variables["AML_COMPUTE_CLUSTER_CPU_SKU"],
        compute_config)

#create environment from conda_dependencies.yml for runconfig
environment = Environment(name="myenv")
conda_dep = CondaDependencies(
    conda_dependencies_file_path="conda_dependencies.yml")
environment.python.conda_dependencies = conda_dep
run_config = RunConfiguration()
run_config.environment = environment

#Dataset creation
dataset_name = variables["DATASET_NAME"]

#Check to see if dataset exists
if (dataset_name not in aml_workspace.datasets):
Exemplo n.º 5
0
      'Azure region: ' + workspace.location,
      'Subscription id: ' + workspace.subscription_id,
      'Resource group: ' + workspace.resource_group,
      sep='\n')

# Getting an Azure ML Compute Target
try:
    compute_target = ComputeTarget(workspace=workspace, name=cluster_name)
    print('Found existing compute target')
except ComputeTargetException:
    print('Creating a new compute target...')
    compute_config = AmlCompute.provisioning_configuration(
        vm_size='STANDARD_D3_V2', max_nodes=1)

    # create the cluster
    compute_target = ComputeTarget.create(workspace, cluster_name,
                                          compute_config)

    # can poll for a minimum number of nodes and for a specific timeout.
    # if no min node count is provided it uses the scale settings for the cluster
    compute_target.wait_for_completion(show_output=True,
                                       min_node_count=None,
                                       timeout_in_minutes=20)

# store the connection string in AML workspace Key Vault
# (secret name is 'debugrelay-' + MD5(azrelay_connection_string) )
#hybrid_connection_string_secret =\
#    f"debugrelay-{hashlib.md5(azrelay_connection_string.encode('utf-8')).hexdigest()}"
#workspace.get_default_keyvault().set_secret(hybrid_connection_string_secret, azrelay_connection_string)

# Configuring a PythonScriptStep with a RunConfiguration
# that includes debugpy and azure-debug-relay