0

I've looked through lots of documentation online, but it all seems to discuss how to create and delete compute in Azure.

I already have a compute instance set up in my ML Workspace that I want to start via a python script. I don't want to click a button on the web portal.

Does anyone have some advice? Thank you.

I have tried lots of resources including Unable to start/stop compute instance through azure machine learning using python and https://learn.microsoft.com/en-us/azure/machine-learning/how-to-create-compute-instance?view=azureml-api-2&tabs=python

1 Answers1

0

To start or stop the compute instence from python SDK you can use ComputeInstance Class from azureml.core.compute.

Below is a sample code snippet to do this:

from  azureml.core.compute  import  ComputeTarget, ComputeInstance
from  azureml.core  import  Workspace

ws=Workspace.from_config()
compute_name="compute_name"
instance = ComputeInstance(workspace=ws, name=compute_name)
#To start
instance.start(wait_for_completion=True, show_output=True)
#To stop
instance.stop(wait_for_completion=True, show_output=True)

enter image description here enter image description here

For more details, please refer to this documentation.

RishabhM
  • 525
  • 1
  • 5