ModuleNotFoundError: No module named 'azureml.train'

Julie 0 Reputation points
2023-02-07T01:07:32.72+00:00

I am following the chalenge: "How to predict many protein structures with AlphaFold2 at-scale in Azure Machine Learning"

https://colbyford.medium.com/how-to-predict-many-protein-structures-with-alphafold2-at-scale-in-azure-machine-learning-c1e0ece4e99f

I run the pipeline below:

from azureml.core import Experiment, ScriptRunConfig, Environment

from azureml.core.conda_dependencies import CondaDependencies

from azureml.train.hyperdrive import GridParameterSampling, RandomParameterSampling, HyperDriveConfig, PrimaryMetricGoal, choice

from azureml.widgets import RunDetails

## Create a Python environment for the experiment

alphafold2_env = Environment("alphafold2")

alphafold2_env.docker.base_image = "cford38/alphafold2_aml:latest"

alphafold2_env.python.user_managed_dependencies = True

## Create a script config

script_config = ScriptRunConfig(source_directory = ".",

                            *script='predict.py',*

                            *arguments = ['--msa_mode', "MMseqs2 (UniRef+Environmental)",*

                                         *'--num_models', 1,*

                                         *'--num_recycles', 3,*

                                         *'--stop_at_score', 90],*

                            *environment = alphafold2_env,*

                            *compute_target = training_cluster)*

## Sample a range of parameter values

params = GridParameterSampling({ '--sequence_id': choice('alpha_b117_6xc2', 'beta_b1351_7vx1', 'delta_b1617_7v70', 'omicron_b11529_7t9j') })

## Configure hyperdrive settings

hyperdrive = HyperDriveConfig(run_config = script_config,

                          *hyperparameter_sampling = params,* 

                          *policy = None,* 

                          *primary_metric_name = 'complete',* 

                          *primary_metric_goal = PrimaryMetricGoal.MAXIMIZE,* 

                          *max_total_runs = 4,*

                          *max_concurrent_runs = 3)*

I receive the following notifications at the end:

ModuleNotFoundError                       Traceback (most recent call last)
Input In [10], in <cell line: 3>()
      1 from azureml.core import Experiment, ScriptRunConfig, Environment
      2 from azureml.core.conda_dependencies import CondaDependencies
----> 3 from azureml.train.hyperdrive import GridParameterSampling, RandomParameterSampling, HyperDriveConfig, PrimaryMetricGoal, choice
      4 from azureml.widgets import RunDetails
      6 ## Create a Python environment for the experiment

ModuleNotFoundError: No module named 'azureml.train'

It appears that "azureml.train" is an uninstalled module. But I did set it up.

Best

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,340 questions
Windows for business | Windows Client for IT Pros | Storage high availability | Virtualization and Hyper-V
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 44,766 Reputation points
    2023-02-07T16:39:28.6733333+00:00

    Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query

    The "ModuleNotFoundError: No module named 'azureml.train'" error message in Python indicates that the "azureml.train" module is not installed in your environment. This error message typically occurs when you try to import the "azureml.train" module in your Python code, but the module is not available in your Python environment.

    To resolve this issue, you can try installing the "azureml.train" module using the following command in your terminal or command prompt:

    pip install azureml-sdk[automl,notebooks,explain,train]

    This command installs the "azureml-sdk" package along with its required dependencies, including the "azureml.train" module. Once the installation is complete, you should be able to import the "azureml.train" module in your code without encountering any errors.

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    2 people found this answer helpful.
    0 comments No comments

  2. Ramr-msft 17,826 Reputation points
    2023-02-09T06:53:04+00:00

    @Julie Thanks for the question. Can you please add more details about the azure ML SDK version that you are using?

    It looks like you are using an older version of the Azure Machine Learning SDK. The azureml.train module was introduced in version 1.0.85 of the Azure Machine Learning SDK. You can check the version of the Azure Machine Learning SDK that you have installed by running the following code:

    import azureml.core
    print(azureml.core.VERSION)
    

    If the version of the Azure Machine Learning SDK that you have installed is older than 1.0.85, you can update it by running the following command:

    !pip install --upgrade azureml-sdk[notebooks,automl,explain,contrib]
    

    After updating the Azure Machine Learning SDK, you should be able to import the azureml.train module and use it in your code.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.