没有这样的文件或目录:'docker': 'docker' when 运行 sagemaker studio 处于本地模式

No such file or directory: 'docker': 'docker' when running sagemaker studio in local mode

我尝试在 amazon sagemaker studio 上训练一个 pytorch 模型。

当我使用 EC2 进行训练时,它工作正常:

estimator = PyTorch(entry_point='train_script.py',
                role=role,
                sagemaker_session = sess,
                train_instance_count=1,
                train_instance_type='ml.c5.xlarge',
                framework_version='1.4.0', 
                source_dir='.',
                git_config=git_config, 
               )
estimator.fit({'stockdata': data_path})

它在经典的 sagemaker 笔记本(非工作室)中以本地模式工作:

 estimator = PyTorch(entry_point='train_script.py',
                role=role,
                train_instance_count=1,
                train_instance_type='local',
                framework_version='1.4.0', 
                source_dir='.',
                git_config=git_config, 
               )
estimator.fit({'stockdata': data_path})

但是当我在 sagemaker studio 上使用相同的代码(使用 train_instance_type='local')时它不起作用并且出现以下错误:没有这样的文件或目录:'docker': 'docker'

我尝试使用 pip install 安装 docker,但是如果在终端中使用 docker 命令则找不到

这表示查找 Docker 服务时出现问题。

默认情况下,Docker 未安装在 SageMaker Studio (confirming github ticket response) 中。

为将近 2 年的问题添加更多信息。

SageMaker Studio 本身不支持 local mode。 Studio 应用程序本身是 docker 容器,因此如果它们能够构建和 运行 docker 容器,它们需要 privileged 访问权限。

作为替代解决方案,您可以在 EC2 实例上创建远程 docker 主机并在您的 Studio 应用程序上设置 docker。涉及相当多的网络和包安装,但该解决方案将使您能够使用完整的 docker 功能。此外,从 SageMaker Python SDK 的版本 2.80.0 开始,当您使用远程 docker 主机时,它现在支持 local mode

sdocker(见此repo) can simplify deploying the above solution in simple two steps (only works for Studio Domain in VPCOnly mode) and it has an easy to follow example here