question

JeswinGeorge-3715 avatar image
1 Vote"
JeswinGeorge-3715 asked AndriusBertulis-6840 answered

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

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
image.png (55.3 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@JeswinGeorge-3715 Thanks for the question. Can you please add more details about the environment and steps that you performed. Here is the link to add required packages.
Please follow the document to Create & use software environments in Azure Machine Learning and here is the link to the samples.

https://docs.microsoft.com/en-in/azure/machine-learning/how-to-use-environments


0 Votes 0 ·
JeswinGeorge-3715 avatar image
0 Votes"
JeswinGeorge-3715 answered

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.






temp1.png (17.2 KiB)
60-control-log.txt (321.7 KiB)
image.png (53.7 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndriusBertulis-6840 avatar image
0 Votes"
AndriusBertulis-6840 answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.