1

我有一个用于文本预测的自定义算法。我想在 sagemaker 中部署它。我正在关注本教程。 https://docs.aws.amazon.com/sagemaker/latest/dg/tf-example1.html
本教程的唯一变化是。

from sagemaker.tensorflow import TensorFlow

iris_estimator = TensorFlow(entry_point='/home/ec2-user/SageMaker/sagemaker.py',
                        role=role,
                        output_path=model_artifacts_location,
                        code_location=custom_code_upload_location,
                        train_instance_count=1,
                        train_instance_type='ml.c4.xlarge',
                        training_steps=1000,
                        evaluation_steps=100, source_dir="./", requirements_file="requirements.txt")

.

%%time
import boto3

train_data_location = 's3://sagemaker-<my bucket>'

iris_estimator.fit(train_data_location)

INFO:数据集位于桶的根部。

错误日志

ValueError: Error training sagemaker-tensorflow-2018-06-19-07-11-13-634: Failed Reason: AlgorithmError: uncaught exception during training: Import by filename is not supported.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/container_support/training.py", line 36, in start
    fw.train()
  File "/usr/local/lib/python2.7/dist-packages/tf_container/train_entry_point.py", line 143, in train
    customer_script = env.import_user_module()
  File "/usr/local/lib/python2.7/dist-packages/container_support/environment.py", line 101, in import_user_module
    user_module = importlib.import_module(script)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: Import by filename is not supported.
4

2 回答 2

1

我解决了这个问题,问题是使用绝对路径entry_point
当您使用source_dir参数时,路径entry_point应该相对于source_dir

于 2018-06-22T08:18:26.467 回答
0

我解决了:

region = boto3.Session().region_name
train_data_location = 's3://sagemaker-<my bucket>'.format(region)
于 2020-01-14T16:29:11.427 回答