当前位置: 首页>>代码示例>>Python>>正文


Python AmlCompute.provisioning_configuration方法代码示例

本文整理汇总了Python中azureml.core.compute.AmlCompute.provisioning_configuration方法的典型用法代码示例。如果您正苦于以下问题:Python AmlCompute.provisioning_configuration方法的具体用法?Python AmlCompute.provisioning_configuration怎么用?Python AmlCompute.provisioning_configuration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在azureml.core.compute.AmlCompute的用法示例。


在下文中一共展示了AmlCompute.provisioning_configuration方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_cluster

# 需要导入模块: from azureml.core.compute import AmlCompute [as 别名]
# 或者: from azureml.core.compute.AmlCompute import provisioning_configuration [as 别名]
def _create_cluster(
    workspace,
    cluster_name=_CLUSTER_NAME,
    vm_size=_CLUSTER_VM_SIZE,
    min_nodes=_CLUSTER_MIN_NODES,
    max_nodes=_CLUSTER_MAX_NODES,
):
    logger = logging.getLogger(__name__)
    try:
        compute_target = ComputeTarget(workspace=workspace, name=cluster_name)
        logger.info("Found existing compute target.")
    except ComputeTargetException:
        logger.info("Creating a new compute target...")
        compute_config = AmlCompute.provisioning_configuration(
            vm_size=vm_size, min_nodes=min_nodes, max_nodes=max_nodes
        )

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

    # use get_status() to get a detailed status for the current AmlCompute.
    logger.debug(compute_target.get_status().serialize())

    return compute_target 
开发者ID:microsoft,项目名称:DistributedDeepLearning,代码行数:27,代码来源:aml_compute.py

示例2: _get_compute_target

# 需要导入模块: from azureml.core.compute import AmlCompute [as 别名]
# 或者: from azureml.core.compute.AmlCompute import provisioning_configuration [as 别名]
def _get_compute_target(self, ws, cluster_name):
        compute_min_nodes = int(self.ctx.config.get('cluster/min_nodes',1))
        compute_max_nodes = int(self.ctx.config.get('cluster/max_nodes',4))
        compute_sku = self.ctx.config.get('cluster/type','STANDARD_D2_V2')

        if cluster_name in ws.compute_targets:
            compute_target = ws.compute_targets[cluster_name]
            if compute_target and type(compute_target) is AmlCompute:
                ct_status = compute_target.get_status()
                if ct_status:
                    ct_def = ct_status.serialize()
                    if ct_def.get('vmSize') == compute_sku and \
                       ct_def.get('scaleSettings', {}).get('minNodeCount') == compute_min_nodes and \
                       ct_def.get('scaleSettings', {}).get('maxNodeCount') == compute_max_nodes:
                        self.ctx.log(
                            'Found compute target %s ...' % cluster_name)

                        return compute_target
                    else:    
                        self.ctx.log('Delete existing AML compute context, since parameters has been modified.')
                        compute_target.delete()

                # It works versy slow, so just change name        
                # cluster_name = self._fix_name(shortuuid.uuid())
                # self.ctx.config.set('cluster/name', cluster_name)
                # self.ctx.config.write()
                try:
                    compute_target.wait_for_completion(show_output = True)
                except Exception as e:
                    self.ctx.log_debug(str(e))    

        self.ctx.log('Creating new AML compute context %s...'%cluster_name)
        provisioning_config = AmlCompute.provisioning_configuration(
            vm_size=compute_sku, min_nodes=compute_min_nodes,
            max_nodes=compute_max_nodes)
        compute_target = ComputeTarget.create(
            ws, cluster_name, provisioning_config)
        compute_target.wait_for_completion(show_output = True)

        return compute_target 
开发者ID:augerai,项目名称:a2ml,代码行数:42,代码来源:experiment.py

示例3: _create_cluster

# 需要导入模块: from azureml.core.compute import AmlCompute [as 别名]
# 或者: from azureml.core.compute.AmlCompute import provisioning_configuration [as 别名]
def _create_cluster(workspace, cluster_name, vm_size, min_nodes, max_nodes):
    """Creates AzureML cluster

    Args:
        cluster_name (string): The name you wish to assign the cluster.
        vm_size (string): The type of sku to use for your vm.
        min_nodes (int): Minimum number of nodes in cluster.
                                    Use 0 if you don't want to incur costs when it isn't being used.
        max_nodes (int): Maximum number of nodes in cluster.

    """
    logger = logging.getLogger(__name__)
    try:
        compute_target = ComputeTarget(workspace=workspace, name=cluster_name)
        logger.info("Found existing compute target.")
    except ComputeTargetException:
        logger.info("Creating a new compute target...")
        compute_config = AmlCompute.provisioning_configuration(
            vm_size=vm_size, min_nodes=min_nodes, max_nodes=max_nodes
        )

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

    # use get_status() to get a detailed status for the current AmlCompute.
    logger.debug(compute_target.get_status().serialize())

    return compute_target 
开发者ID:microsoft,项目名称:seismic-deeplearning,代码行数:31,代码来源:experiment.py

示例4: get_compute

# 需要导入模块: from azureml.core.compute import AmlCompute [as 别名]
# 或者: from azureml.core.compute.AmlCompute import provisioning_configuration [as 别名]
def get_compute(workspace: Workspace, compute_name: str, vm_size: str, for_batch_scoring: bool = False):  # NOQA E501
    try:
        if compute_name in workspace.compute_targets:
            compute_target = workspace.compute_targets[compute_name]
            if compute_target and type(compute_target) is AmlCompute:
                print("Found existing compute target " + compute_name + " so using it.") # NOQA
        else:
            e = Env()
            compute_config = AmlCompute.provisioning_configuration(
                vm_size=vm_size,
                vm_priority=e.vm_priority if not for_batch_scoring else e.vm_priority_scoring,  # NOQA E501
                min_nodes=e.min_nodes if not for_batch_scoring else e.min_nodes_scoring,  # NOQA E501
                max_nodes=e.max_nodes if not for_batch_scoring else e.max_nodes_scoring,  # NOQA E501
                idle_seconds_before_scaledown="300"
                #    #Uncomment the below lines for VNet support
                #    vnet_resourcegroup_name=vnet_resourcegroup_name,
                #    vnet_name=vnet_name,
                #    subnet_name=subnet_name
            )
            compute_target = ComputeTarget.create(
                workspace, compute_name, compute_config
            )
            compute_target.wait_for_completion(
                show_output=True, min_node_count=None, timeout_in_minutes=10
            )
        return compute_target
    except ComputeTargetException as ex:
        print(ex)
        print("An error occurred trying to provision compute.")
        exit(1) 
开发者ID:microsoft,项目名称:MLOpsPython,代码行数:32,代码来源:attach_compute.py

示例5: get_or_create_amlcompute

# 需要导入模块: from azureml.core.compute import AmlCompute [as 别名]
# 或者: from azureml.core.compute.AmlCompute import provisioning_configuration [as 别名]
def get_or_create_amlcompute(
    workspace, compute_name, vm_size="", min_nodes=0, max_nodes=None, idle_seconds_before_scaledown=None, verbose=False,
):
    """
        Get or create AmlCompute as the compute target. If a cluster of the same name is found,
        attach it and rescale accordingly. Otherwise, create a new cluster.

    Args:
        workspace (Workspace): workspace
        compute_name (str): name
        vm_size (str, optional): vm size
        min_nodes (int, optional): minimum number of nodes in cluster
        max_nodes (None, optional): maximum number of nodes in cluster
        idle_seconds_before_scaledown (None, optional): how long to wait before the cluster
            autoscales down
        verbose (bool, optional): if true, print logs
    Returns:
        Compute target
    """
    try:
        if verbose:
            print("Found compute target: {}".format(compute_name))

        compute_target = ComputeTarget(workspace=workspace, name=compute_name)
        if len(compute_target.list_nodes()) < max_nodes:
            if verbose:
                print("Rescaling to {} nodes".format(max_nodes))
            compute_target.update(max_nodes=max_nodes)
            compute_target.wait_for_completion(show_output=verbose)

    except ComputeTargetException:
        if verbose:
            print("Creating new compute target: {}".format(compute_name))

        compute_config = AmlCompute.provisioning_configuration(
            vm_size=vm_size,
            min_nodes=min_nodes,
            max_nodes=max_nodes,
            idle_seconds_before_scaledown=idle_seconds_before_scaledown,
        )
        compute_target = ComputeTarget.create(workspace, compute_name, compute_config)
        compute_target.wait_for_completion(show_output=verbose)

    return compute_target 
开发者ID:microsoft,项目名称:forecasting,代码行数:46,代码来源:azureml_utils.py

示例6: get_or_create_amlcompute

# 需要导入模块: from azureml.core.compute import AmlCompute [as 别名]
# 或者: from azureml.core.compute.AmlCompute import provisioning_configuration [as 别名]
def get_or_create_amlcompute(
    workspace,
    compute_name,
    vm_size="",
    min_nodes=0,
    max_nodes=None,
    idle_seconds_before_scaledown=None,
    verbose=False,
):
    """
        Get or create AmlCompute as the compute target. If a cluster of the same name is found,
        attach it and rescale accordingly. Otherwise, create a new cluster.

    Args:
        workspace (Workspace): workspace
        compute_name (str): name
        vm_size (str, optional): vm size
        min_nodes (int, optional): minimum number of nodes in cluster
        max_nodes (None, optional): maximum number of nodes in cluster
        idle_seconds_before_scaledown (None, optional): how long to wait before the cluster
            autoscales down
        verbose (bool, optional): if true, print logs
    Returns:
        Compute target
    """
    try:
        if verbose:
            print("Found compute target: {}".format(compute_name))

        compute_target = ComputeTarget(workspace=workspace, name=compute_name)
        if len(compute_target.list_nodes()) < max_nodes:
            if verbose:
                print("Rescaling to {} nodes".format(max_nodes))
            compute_target.update(max_nodes=max_nodes)
            compute_target.wait_for_completion(show_output=verbose)

    except ComputeTargetException:
        if verbose:
            print("Creating new compute target: {}".format(compute_name))

        compute_config = AmlCompute.provisioning_configuration(
            vm_size=vm_size,
            min_nodes=min_nodes,
            max_nodes=max_nodes,
            idle_seconds_before_scaledown=idle_seconds_before_scaledown,
        )
        compute_target = ComputeTarget.create(workspace, compute_name, compute_config)
        compute_target.wait_for_completion(show_output=verbose)

    return compute_target 
开发者ID:microsoft,项目名称:nlp-recipes,代码行数:52,代码来源:azureml_utils.py


注:本文中的azureml.core.compute.AmlCompute.provisioning_configuration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。