# GPT-J fails on Amazon Sagemaker

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgpt-j-fails-on-amazon-sagemaker%2F20369%3E%5C
**Category:** Models\
**Created:** [July 14, 2022, 8:50am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgpt-j-fails-on-amazon-sagemaker%2F20369 "2022-07-14T08:50:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rococode](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/rococode/32/5363_2.png) [@rococode](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Frococode)%5C
**Post date:** [July 14, 2022, 8:50am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgpt-j-fails-on-amazon-sagemaker%2F20369%2F1 "2022-07-14T08:50:13Z")

</div>

I am trying to deploy a GPT-J instance on sagemaker.

This is my Jupyter notebook sample

```auto
from sagemaker.huggingface import HuggingFaceModel
import sagemaker

# IAM role with permissions to create endpoint
role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'EleutherAI/gpt-j-6B',
	'HF_TASK':'text-generation'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.4xlarge' #'ml.m5.xlarge' # ec2 instance type
)

```

What I basically changed from the model suggestion is the instance name.  
When calling the endpoing I keep getting errors which I assume are due to latency or memory

Example of error:

```auto
ReadTimeoutError: Read timeout on endpoint URL: "https://runtime.sagemaker.eu-central-1.amazonaws.com/endpoints/huggingface-pytorch-inference-xxxx-xxx-xxx-xx-xx-xx/invocations"

```

This is on the latest image which I’ve been switching

Anyone can point out something I’m doing wrong?

I would like to point out that I’m just starting with using ML models so I don’t have a lot of background knowledge

Thanks

---

<div class="post-metadata">

**Author:** ![YannAgora](https://avatars.discourse-cdn.com/v4/letter/y/c0e974/32.png) [@YannAgora](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FYannAgora)%5C
**Post date:** [July 15, 2022, 9:11am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgpt-j-fails-on-amazon-sagemaker%2F20369%2F2 "2022-07-15T09:11:13Z")

</div>

Hey 👋

You might find solutions in this blog article [Deploy GPT-J 6B for inference using Hugging Face Transformers and Amazon SageMaker](https://huggingface.co/blog/gptj-sagemaker)

---

<div class="post-metadata">

**Author:** ![rococode](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/rococode/32/5363_2.png) [@rococode](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Frococode)%5C
**Post date:** [July 21, 2022, 2:31pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgpt-j-fails-on-amazon-sagemaker%2F20369%2F3 "2022-07-21T14:31:49Z")

</div>

Thanks a lot!  
It kinda works. I still get a lot of out of memory errors, but I’ll mark it as the solution for now!
