How to resolve error - Creating conda environment failed with exit code: 1?

Jeswin George 6 Reputation points
2021-08-21T14:57:38.217+00:00

I am getting this error when I run script job_submit.py. I do not know how to debug this issue, would appreciate help to solve this.

PS: I have just started learning azure so I am not sure what I am missing.

125147-image.png

script_to_run.py

   from azureml.core import Workspace, Dataset, Run  
     
   ws = Workspace.from_config()  
   az_dataset = Dataset.get_by_name(workspace=ws, name='titanic-dataset')  
     
   # Get the context of the experiment  
   new_run = Run.get_context()  
     
   df = az_dataset.to_pandas_dataframe()  
   ### count the observations  
   total_obs = len(df)  
   ### get the gender count  
   gender_count = df['Sex'].value_counts()  
     
     
   # log the metrics to workspace  
   new_run.log(name = "Total observations", value = total_obs)  
   ### Log the gender data values  
   for val in df['Sex'].unique():  
       new_run.log(name = val, value = gender_count[val])  
     
   # complete an experiment run  
   new_run.complete()  

job_submit.py

   from azureml.core import Workspace, Datastore, Dataset, Experiment, ScriptRunConfig, Environment  
   # Access workspace  
   ws = Workspace.from_config()  
   # create an experiment object  
   exp = Experiment(workspace=ws, name = "Titanic_exp")  
     
   # create custom env - myenv  
   myenv = Environment(name = 'MyEnvironment')  
   # to install dependencies  
   from azureml.core.environment import CondaDependencies  
     
   # from CondaDependencies class we need to create an object which will have all the required dependencies  
   # create the dependencies object  
   packages = CondaDependencies.create(conda_packages=['pandas', 'scikit-learn']) # this will have list of all packages we will need  
   myenv.python.conda_dependencies = packages # this will tell to install the packages  
     
   # register environment to workspace so that we have access to it  
   myenv.register(ws)  
     
   # create a script configuration for custom env  
   script_config = ScriptRunConfig(source_directory = '.', script = "script_to_run.py", environment = myenv)  
     
   new_run = exp.submit(config = script_config)  
Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,575 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Jeswin George 6 Reputation points
    2021-08-24T01:12:50.137+00:00

    Hi @Ramr-msft thanks for replying.
    I am following this link to learn azureml: 4-azure-ml-experiment

    I did the following steps:

    1. Created the workspace, downloaded the config.json file and uploaded it in the .azureml folder created by me.
    2. I was able to successfully run this script using experiment.start_logging() function as given in the module. 125680-temp1.png
    3. The problem comes when i try to run the script as an experiment using Run.get_context()125769-60-control-log.txt
      125757-image.png
    4. I am attaching the 60_control_log.txt for reference.

    Please let me know if this answers your question and helps you to figure out the issue.

    0 comments No comments

  2. Andrius Bertulis 1 Reputation point
    2021-09-07T11:52:30.913+00:00

    Hey, I was having the same issue. resolved in two steps, however i think you can skip step 1

    -- step 1 (not sure if this actually had any impact but did not retest with default setup)
    I have modified the environment.yml fiIe and specified a python version as 3.8.10
    -- step 2 (I think this did the trick)
    Created new compute instance and rerun

    Hope same works for you

    0 comments No comments