子目录中的 AWS SageMaker SKLearn 入口点?
AWS SageMaker SKLearn entry point in a subdirectory?
我可以将 SageMaker estimator 的入口点脚本指定在子目录中吗?到目前为止,它对我来说失败了。这是我想要做的:
sklearn = SKLearn(
entry_point="RandomForest/my_script.py",
source_dir="../",
hyperparameters={...
我想这样做,这样我就不必破坏我的目录结构。我有一些模块,我在几个 sagemaker 项目中使用它们,每个项目都在自己的目录中:
my_git_repo/
RandomForest/
my_script.py
my_sagemaker_notebook.ipynb
TensorFlow/
my_script.py
my_other_sagemaker_notebook.ipynb
module_imported_in_both_scripts.py
如果我尝试 运行 这个,SageMaker 会失败,因为它似乎解析入口点脚本的名称以从中生成模块名称,但它做得不好:
/usr/bin/python3 -m RandomForest/my_script --bootstrap True --case nf_2 --max_features 0.5 --min_impurity_decrease 5.323785009485933e-06 --model_name model --n_estimators 455 --oob_score True
...
/usr/bin/python3: No module named RandomForest/my_script
除了将 my_script.py
放入 source_dir
之外,有人知道解决这个问题的方法吗?
不幸的是,这是功能上的差距。 https://github.com/aws/sagemaker-python-sdk/pull/941 中有一些相关工作也应该可以解决这个问题,但是现在,您需要将 my_script.py
放入 source_dir
.
如果你这样做会怎样 source_dir = my_git_repo/RandomForest
?
否则,您还可以使用构建功能(例如 CodeBuild - but it could also be some custom code eg in Lambda or Airflow) to send your script as a compressed artifact to s3, as this is how lower level SDKs such as boto3 expect your script anyway; this type of integration is shown in the boto3 section of the SageMaker Sklearn random forest demo
我可以将 SageMaker estimator 的入口点脚本指定在子目录中吗?到目前为止,它对我来说失败了。这是我想要做的:
sklearn = SKLearn(
entry_point="RandomForest/my_script.py",
source_dir="../",
hyperparameters={...
我想这样做,这样我就不必破坏我的目录结构。我有一些模块,我在几个 sagemaker 项目中使用它们,每个项目都在自己的目录中:
my_git_repo/
RandomForest/
my_script.py
my_sagemaker_notebook.ipynb
TensorFlow/
my_script.py
my_other_sagemaker_notebook.ipynb
module_imported_in_both_scripts.py
如果我尝试 运行 这个,SageMaker 会失败,因为它似乎解析入口点脚本的名称以从中生成模块名称,但它做得不好:
/usr/bin/python3 -m RandomForest/my_script --bootstrap True --case nf_2 --max_features 0.5 --min_impurity_decrease 5.323785009485933e-06 --model_name model --n_estimators 455 --oob_score True
...
/usr/bin/python3: No module named RandomForest/my_script
除了将 my_script.py
放入 source_dir
之外,有人知道解决这个问题的方法吗?
不幸的是,这是功能上的差距。 https://github.com/aws/sagemaker-python-sdk/pull/941 中有一些相关工作也应该可以解决这个问题,但是现在,您需要将 my_script.py
放入 source_dir
.
如果你这样做会怎样 source_dir = my_git_repo/RandomForest
?
否则,您还可以使用构建功能(例如 CodeBuild - but it could also be some custom code eg in Lambda or Airflow) to send your script as a compressed artifact to s3, as this is how lower level SDKs such as boto3 expect your script anyway; this type of integration is shown in the boto3 section of the SageMaker Sklearn random forest demo