# Infer on sagemaker with custom pipeline

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finfer-on-sagemaker-with-custom-pipeline%2F51448%3E%5C
**Category:** Amazon SageMaker\
**Created:** [August 21, 2023, 12:41am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finfer-on-sagemaker-with-custom-pipeline%2F51448 "2023-08-21T00:41:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![EpivolisAndy](https://avatars.discourse-cdn.com/v4/letter/e/c0e974/32.png) [@EpivolisAndy](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FEpivolisAndy)%5C
**Post date:** [August 21, 2023, 12:41am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finfer-on-sagemaker-with-custom-pipeline%2F51448%2F1 "2023-08-21T00:41:45Z")

</div>

I have a model that I want to use a custom pipeline for, how would I modify the following to use my custom pipeline code?

```auto
from sagemaker.huggingface.model import HuggingFaceModel
hub = {
  'HF_TASK':'my-custom-pipeline',
}
huggingface_model = HuggingFaceModel(
   model_data="s3://model/model.tar.gz", # path to your trained SageMaker model
   env=hub,
   role=role, # IAM role with permissions to create an endpoint
   transformers_version="4.28", # Transformers version used
   pytorch_version="2.0", # PyTorch version used
   py_version='py310', # Python version used
)

```

---

<div class="post-metadata">

**Author:** ![philschmid](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/philschmid/32/38022_2.png) [@philschmid](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fphilschmid)%5C
**Post date:** [August 21, 2023, 6:13am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finfer-on-sagemaker-with-custom-pipeline%2F51448%2F2 "2023-08-21T06:13:44Z")

</div>

see: [Creating document embeddings with Hugging Face's Transformers & Amazon SageMaker](https://www.philschmid.de/custom-inference-huggingface-sagemaker)

---

<div class="post-metadata">

**Author:** ![EpivolisAndy](https://avatars.discourse-cdn.com/v4/letter/e/c0e974/32.png) [@EpivolisAndy](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FEpivolisAndy)%5C
**Post date:** [September 14, 2023, 2:49am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finfer-on-sagemaker-with-custom-pipeline%2F51448%2F3 "2023-09-14T02:49:45Z")

</div>

Seems like if I don’t pass in an env, it wouldn’t work, even if I have my own custom inference.py

It’s forcing me to choose from one of the pre-existing pipelines but I have custom code for inference. Am I forced to provide a parameter here?
