# Create batch transform with existing model

**URL:** <https://discuss.huggingface.co/t/create-batch-transform-with-existing-model/29158>\
**Category:** Amazon SageMaker\
**Created:** [January 8, 2023, 9:55am UTC](https://discuss.huggingface.co/t/create-batch-transform-with-existing-model/29158 "2023-01-08T09:55:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MPA](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@MPA](https://discuss.huggingface.co/u/MPA)\
**Post date:** [January 8, 2023, 9:55am UTC](https://discuss.huggingface.co/t/create-batch-transform-with-existing-model/29158/1 "2023-01-08T09:55:04Z")

</div>

Hi,  
I have issue to run a batch transform with existing model created with sagemaker SDK.

Here is the code that create a model and run a transform job.

```auto
    def create_sagemaker_model(self):
        print('creating sagemaker model')
        sagemaker_model = HuggingFaceModel(
            model_data=self.model_path,
            role=self.sagemaker_role,
            source_dir=Config.SG_SOURCE_DIR,
            transformers_version=self.transformers_version,
            pytorch_version=self.pytorch_version,
            py_version=self.py_version,
            entry_point=Config.SG_ENTRY_POINT,
            env=self.environment_vars,
            sagemaker_session=get_sagemaker_session(self.instance_type)
        )
        return sagemaker_model

    def create_batch_job(self):
        print('creating batch job')
        sagemaker_model = self.create_sagemaker_model()
        batch_job = sagemaker_model.transformer(
            instance_count=self.instance_count,
            instance_type=self.instance_type,
            output_path=self.output_s3_path,
            strategy=self.strategy,
            accept=self.content_type,
            assemble_with=self.split_type
        )
        return batch_job

    def create_and_run_batch_job(self):
        print('creating and running batch job')
        batch_job = self.create_batch_job()
        batch_job.transform(
            job_name=self.batch_job_name,
            data=self.s3_uri,
            content_type=self.content_type,
            split_type=self.split_type,
            wait=False
        )
        return batch_job

```

I can’t find in the documentation how to run a batch transform job without creating new model.  
I tried:

```auto
def serve(args):
    transformer = Transformer(
        model_name=args.model_name,
        output_path=args.output_data or args.input_data,
        instance_count=args.instance_count,
        instance_type=args.instance_type,
        accept=args.accept,
        assemble_with=args.assemble_with,
        strategy=args.strategy,
        max_payload=70,
        env={'SAGEMAKER_MODEL_SERVER_TIMEOUT': '36000'}
    )
    print(f'Starting transform job')
    transformer.transform(
        args.input_data,
        content_type=args.accept,
        join_source=args.join_source,
        split_type=args.assemble_with,
        wait=False
    )

```

but there is exception -

```auto
ValueError: Failed to fetch model information for huggingface-pytorch-inference-2023-01-06-22-25-13-167. Please ensure that the model exists. Local instance types require locally created models.

```

While i can execute the job with the sagemaker web UI.  
Thanks
