1

When I tried to run a Batch transform job in AWS SageMaker, I met below error:

ImportError: No module named cv2

Please note that, I am able to "import CV2" in the notebook instance. The jupter can run "import CV2" in notebook instance. But failed to run it in endpoints during inference time. I have tried below method using "env" as the link AWS Sagemaker - Install External Library and Make it Persist

but it still not work.

anyone have good way to solve it? Thanks!

my codes are:

env = {
'SAGEMAKER_REQUIREMENTS': 'requirements.txt', # path relative to `source_dir` below.
}
image_embed_model = MXNetModel(model_data=model_data,
                         entry_point='sagemaker_entrypoint.py',
                        role=role,
                        source_dir = 'src',
                        env = env,
                        py_version='py3',
                        framework_version='1.6.0')

transformer = image_embed_model.transformer(instance_count=1, # Please pay attention here!!!
                                    instance_type='ml.m4.xlarge',
                                    output_path=output_path,
                                    assemble_with = 'Line', 
                                    accept = 'text/csv'
                                   )
transformer.transform(batch_input,
                  content_type='text/csv', 
                  split_type='Line',
                  input_filter='$[0:]',
                  join_source='Input',
                  wait=False)
Community
  • 1
  • 1
wsypy
  • 11
  • 2

1 Answers1

0

You can follow https://github.com/aws/sagemaker-python-sdk/blob/master/doc/using_mxnet.rst#use-third-party-libraries to import third party libraries to your batch transform instances. Make sure the requirement.txt file is saved under the right directory before packaging the model data.

Alohahaha
  • 96
  • 2