alertFunction commited on
Commit
7e732e4
1 Parent(s): 7a74280

Create deploy-gptj.py

Browse files
Files changed (1) hide show
  1. deploy-gptj.py +25 -0
deploy-gptj.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from sagemaker.huggingface import HuggingFaceModel
3
+ import sagemaker
4
+
5
+ # IAM role with permissions to create endpoint
6
+ role = sagemaker.get_execution_role()
7
+
8
+ # public S3 URI to gpt-j artifact
9
+ model_uri="s3://huggingface-sagemaker-models/transformers/4.12.3/pytorch/1.9.1/gpt-j/model.tar.gz"
10
+
11
+ # create Hugging Face Model Class
12
+ huggingface_model = HuggingFaceModel(
13
+ model_data=model_uri,
14
+ transformers_version='4.12.3',
15
+ pytorch_version='1.9.1',
16
+ py_version='py38',
17
+ role=role,
18
+ )
19
+
20
+ # deploy model to SageMaker Inference
21
+ predictor = huggingface_model.deploy(
22
+ initial_instance_count=1, # number of instances
23
+ instance_type='ml.g4dn.xlarge', #'ml.p3.2xlarge' # ec2 instance type
24
+ endpoint_name='sm-endpoint-gpt-j-6b'
25
+ )