azure-machine-learning-service - 使用 azureml-sdk 写入 azureml 中已安装的文件系统

标签 azure-machine-learning-service azureml-python-sdk

我正在尝试使用 AMLCompute 实例来预处理我的数据。为此,我需要能够将处理后的数据写回数据存储。我采用这种方法是因为集群在完成后会自动关闭,这样我就可以让它运行直到完成,而不必担心付出比需要更多的时间。
问题是当我尝试写回数据存储(作为数据集挂载)时,出现以下错误:

OSError: [Errno 30] Read-only file system: '/mnt/batch/tasks/shared/LS_root/jobs/[...]/wav_test'
我已将数据存储的访问策略设置为允许读取、添加、创建、写入、删除和列出,但我认为这不是问题,因为我已经可以从 Microsoft Azure 文件资源管理器写入数据存储。
有没有办法直接或通过数据集挂载数据存储具有写权限 来自 azureml python sdk?
或者,是否有更好的方法在 azure 上预处理此(音频)数据以进行机器学习?
谢谢!
编辑:
我正在添加一个说明问题的示例。
from azureml.core import Workspace, Dataset, Datastore
import os

ws = Workspace.from_config()
ds = Dataset.get_by_name(ws, name='birdsongs_alldata')

mount_context = ds.mount()
mount_context.start()

os.listdir(mount_context.mount_point)
输出:

['audio_10sec', 'mp3', 'npy', 'resources', 'wav']


所以文件系统被挂载并且可见。
# try to write to the mounted file system
outfile = os.path.join(mount_context.mount_point, 'test.txt')

with open(outfile, 'w') as f:
    f.write('test')
错误:
--------------------------------------------------------------------------- OSError                                   Traceback (most recent call last) <ipython-input-9-1b15714faded> in <module>
      1 outfile = os.path.join(mount_context.mount_point, 'test.txt')
      2 
----> 3 with open(outfile, 'w') as f:
      4     f.write('test')

OSError: [Errno 30] Read-only file system: '/tmp/tmp8ltgsx6x/test.txt'

最佳答案

我已经在我的环境中模拟了相同的场景并且它起作用了。您能否分享问题中的代码和完整的错误消息?
关于成本问题,可以使用aml python sdk用azureml.core.compute启动、停止和等待运行状态。 .通过这种方式,您可以更好地控制“运行”(启动、执行、停止)的计算时间。
处理预处理音频文件的最佳方式取决于它的一些内容。如果音频包含语音,我强烈建议您使用 Azure Cognitive Services - Speech API (speech-to-text) .
如果不是语音,可以使用the wave module ,就像下面的代码:

from wave import open as open_wave
waveFile = open_wave(<filename>,'rb')
nframes = waveFile.getnframes()
wavFrames = waveFile.readframes(nframes)
ys = numpy.fromstring(wavFrames, dtype=numpy.int16)
Credits
此方法并非完全来自 azure,而是允许您以结构化方式使用数据。

关于azure-machine-learning-service - 使用 azureml-sdk 写入 azureml 中已安装的文件系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67081272/

相关文章:

Azure ML 表格数据集 : missing 1 required positional argument: 'stream_column'

excel - Azure机器学习工作室: how to add a dataset from a local Excel file?

python - 带有脚本包的 Azure ML Python 无法导入模块

python-3.x - Azure Web 服务部署在本地如何工作?

azure - 检索 Azure ML v2 的当前作业

python-3.x - 访问 Azure Auto ML 的 Azure 数据存储时出现 SSL 错误

azure - 如果 Azure ML 管道失败,则发送警报

azure-machine-learning-service - Azure ML FileDataset 已注册,但无法访问数据标签项目

AzureML 模型注册