我正在从微软的教程,这里学习Azure。前两个教程运行良好,但这个教程给了我以下错误。
[stderr]Traceback (most recent call last):
[stderr] File "train.py", line 8, in <module>
[stderr] from azureml.core import Run
[stderr]ModuleNotFoundError: No module named 'azureml'
[stderr]使用Azure并将代码提交到环境中,我无法找到如何解决此错误。
我已经检查包是否安装了(运行在Azure工作室上,因此这是基本假设,但我也进行了测试)。下面是代码'run-pytorch.py‘,它调用脚本'train.py’
# run-pytorch.py
from azureml.core import Workspace
from azureml.core import Experiment
from azureml.core import Environment
from azureml.core import ScriptRunConfig
if __name__ == "__main__":
ws = Workspace.from_config()
experiment = Experiment(workspace=ws, name='day1-experiment-train')
config = ScriptRunConfig(source_directory='./src',
script='train.py',
compute_target='cpu-cluster')
# set up pytorch environment
env = Environment.from_conda_specification(
name='pytorch-env',
file_path='pytorch-env.yml'
)
config.run_config.environment = env
run = experiment.submit(config)
aml_url = run.get_portal_url()
print(aml_url)
print('Success...!!!')用于train.py的代码片段如下
# train.py
import os
import argparse
import torch
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
from model import Net
from azureml.core import Run
...
...发布于 2022-02-01 05:22:38
您能否尝试下列疑难解答。我已经看到了这一点,当您的坞中调用的python不使用env时,这里安装了Azureml包,因此是…。
https://stackoverflow.com/questions/70852922
复制相似问题