运行失败:用户程序失败,ModuleNotFoundError:Azure ML Experimen中没有名为“amlrun”的模块

2024-04-19 09:08:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用VS代码在azureportal中提交了一个机器学习实验。运行实验时,我得到以下错误:

运行失败:用户程序失败,ModuleNotFoundError:没有名为“amlrun”的模块

这是代码结构:

.vscode(json配置文件)

反洗钱配置

脚本

-----amlrun.py文件(带有一些函数的脚本)

----型号_培训.py(创建和保存模型的脚本)

这是配置文件:

{
    "script": "model_training.py",
    "framework": "Python",
    "communicator": "None",
    "target": "testazure",
    "environment": {
        "python": {
            "userManagedDependencies": false,
            "condaDependencies": {
                "dependencies": [
                    "python=3.6.2",
                    "scikit-learn",
                    "numpy",
                    "pandas",
                    {
                        "pip": [
                            "azureml-defaults"
                        ]
                    }
                ]
            }
        },
        "docker": {
            "baseImage": "mcr.microsoft.com/azureml/base:0.2.4",
            "enabled": true,
            "baseImageRegistry": {
                "address": null,
                "username": null,
                "password": null
            }
        }
    },
    "history": {
        "outputCollection": true,
        "snapshotProject": false,
        "directoriesToWatch": [
            "logs"
        ]
    }
}

我错过什么了吗? 谢谢


Tags: 代码py脚本机器falsetrue配置文件错误
1条回答
网友
1楼 · 发布于 2024-04-19 09:08:13

当您的培训脚本在azure中运行时,它无法找到所有本地导入,即amlrun.py脚本。你知道吗

提交给azure的培训作业首先用您的文件构建一个docker映像并运行实验;但是在本例中,扩展没有包含amlrun.py。你知道吗

这可能是因为在提交带有扩展名的培训作业时,打开的VisualStudio代码窗口没有指向scripts文件夹。你知道吗

摘自对previously raised github issue的回复之一:

The extension currently requires the script you are working on to be in the folder that is open in VS Code and not in a sub-directory.


要解决此问题,您可以执行以下操作之一:

  1. 您需要在scripts文件夹而不是父目录中重新打开VisualStudio代码。

  2. script目录中的所有文件移到其父目录中。


如果您正在寻找更灵活的方法来提交培训作业和管理aml,那么可以使用azure machine learning sdkfor python。你知道吗

使用SDK管理过期的一些示例可以在以下链接中找到:

  1. Scikit Learn Model Training Docs

  2. Basic Pytorch Model Training and Deployment Example Repo

相关问题 更多 >