当前位置: 首页 > 科技观察

使用PodmanMLCube运行“helloworld”

时间:2023-03-14 11:27:38 科技观察

MLCube是一个新的开源容器,它基于引入到基于Python的机器学习工作流中以实现可重现性的基础设施规范。它可以利用Podman、Singularity和Docker等工具。还支持在远程平台上执行。开发MLCube的MLCommons最佳实践工作组的主席之一是来自RedHat的DianeFeddema。这篇介绍性文章解释了如何在FedoraLinux上使用Podman运行“helloworld”MLCube示例。YazanMonshed在Fedora上写了一篇非常有用的Podman介绍,详细介绍了此处使用的一些步骤。首先安装必要的依赖项。sudodnf-yupdatesudodnf-yinstallpodmangitvirtualenv\policycoreutils-python-utils然后,如文档所述,设置虚拟环境并获取示例代码。为确保可重复性,请使用特定的提交,因为项目正在积极改进中。virtualenv-ppython3./env_mlcubesource./env_mlcube/bin/activategitclonehttps://github.com/mlcommons/mlcube_examples.gitcd./mlcube_examples/hello_worldgitcheckout5fe69bdpipinstallmlcubemlcube-dockermlcubedescribe现在,通过编辑$HOME/mlcube.yaml文件,将runner命令从docker改为podman,即:docker:docker改为:docker:podman如果你使用的是x86_64架构的电脑,可以通过以下方式获取容器:mlcube配置--mlcube=.--platform=docker你会看到一些选项:请选择一个图像:?registry.fedoraproject.org/mlcommons/hello_world:0.0.1registry.access.redhat.com/mlcommons/hello_world:0.0.1docker.io/mlcommons/hello_world:0.0.1quay.io/mlcommons/hello_world:0.0.1选择docker.io/mlcommons/hello_world:0.0.1获取容器。如果您的计算机不是x86_64,则需要构建容器。更改文件$HOME/mlcube.yaml,更改此行:build_strategy:pull到:build_strategy:auto,然后使用:mlcubeconfigure--mlcube=构建容器。--platform=docker要运行测试,您可能需要在目录中适当地设置SELinux权限。您可以通过键入以下内容来检查SELinux是否已启用:sudosestatus应该输出如下内容:SELinuxstatus:enabled...JosphatMutai、ChristopherSmart和DanielWalsh解释说,在设置适当的SELinux策略后,您需要小心。在这里,您将允许容器读取和写入工作区目录。sudosemanagefcontext-a-tcontainer_file_t"$PWD/workspace(/.*)?"sudorestorecon-Rv$PWD/workspace现在检查目录策略:ls-Z输出如下:object_r:user_home_t:s0requirements.txtunconfined_u:object_r:container_file_t:s0workspace现在运行这个例子:mlcube=run--ml-task=hello--platform=dockermlcuberun--mlcube=。--task=bye--platform=docker最后,检查输出:catworkspace/chats/chat_with_alice.txt的文本类似于:嗨,爱丽丝!很高兴见到你。再见,爱丽丝!很高兴和你交谈。您可以按照此处所述创建自己的MLCube。欢迎对MLCube示例存储库做出贡献。Udica是一个新项目,承诺为系统管理员可以轻松应用的容器提供更精细的SELinux策略控制。这些项目的积极开发正在进行中。测试它们并提供反馈将有助于使用SELinux更轻松、更高效地在系统上进行安全数据管理。