I am trying to print a .yml file for an environment. I can do it for this environment:
env = Environment.get(workspace = ws, name = 'AzureML-AutoML', version=115)
print(env)
print(env.python.conda_dependencies.serialize_to_string())
>>>Environment(Name: AzureML-AutoML,
Version: 115)
channels:
- anaconda
- conda-forge
- pytorch
dependencies:
- python=3.7.9
- pip=20.2.4
- pip:
- azureml-core==1.42.0
- azureml-mlflow==1.42.0
...
When I use the same code for this other environment I get an error:
infer_env = 'AzureML-pytorch-1.10-ubuntu18.04-py37-cpu-inference'
curated_pytorch_infer_env = Environment.get(workspace = ws, name = infer_env, version=4)
print(curated_pytorch_infer_env)
print(curated_pytorch_infer_env.python.conda_dependencies.serialize_to_string())
>>> AttributeError: 'NoneType' object has no attribute 'serialize_to_string'
How do I get/print a .yml file for ‘curated_pytorch_infer_env’?
2
Answers
To resolve
AttributeError: 'NoneType' object has no attribute 'serialize_to_string'
try following ways:1. According to Use curated environments:
Note: The name prefix AzureML is reserved for curated environments. Don’t use it for your own environment.
You can try this code snippet taken from the document:
2. Try upgrading to the latest version i.e.
PyTorch 1.12
You can submit a job with the environment that would do conda export in a subprocess. Probably this might work https://learn.microsoft.com/en-us/python/api/azureml-core/azureml.core.environment.environment?view=azure-ml-py#azureml-core-environment-environment-from-existing-conda-environment
Environment name is returned in env.get_image_details(ws) response.
Easiest way might be to pull corresponding image and run it locally to
conda export