I'm just testing AWS tools to serve using sagemaker. My current progress is that I've already created a trained model, and compressed pth, inference.py, requirement.txt, and other necessary files into tar.gz and deployed them to an s3 bucket.
$ tar -tzf birefnet.tar.gz
./
./ckpt/
./ckpt/BiRefNet-general-epoch_244.pth
./config.py
./dataset.py
./evaluation/
./inference.py
./requirements.txt
.
.
Here are the contents of the compressed file. After uploading to the bucket, I tried to load the tar.gz file in the bucket using pytorchmodel in the sagemaker notebook. However, I keep getting an error that inference.py is missing. I tried asking for help from chatgpt and many others, but was unsuccessful. Here is the code I wrote:
import sagemaker
from sagemaker.pytorch import PyTorchModel
sagemaker_session = sagemaker.Session()
role = sagemaker.get_execution_role()
model_data = 's3://sagemaker-birefnet-up/path/to/birefnet.tar.gz'
pytorch_model = PyTorchModel(
model_data=model_data,
role=role,
entry_point='inference.py',
framework_version='2.5.1',
py_version='py311',
sagemaker_session=sagemaker_session
)
predictor = pytorch_model.deploy(
initial_instance_count=1,
instance_type='ml.t2.medium',
)
FileNotFoundError: [Errno 2] No such file or directory: 'inference.py'
What did I do wrong?
I thought what I wanted to do was simple. I tried recompressing and changing the model path, but nothing worked.
I'm just testing AWS tools to serve using sagemaker. My current progress is that I've already created a trained model, and compressed pth, inference.py, requirement.txt, and other necessary files into tar.gz and deployed them to an s3 bucket.
$ tar -tzf birefnet.tar.gz
./
./ckpt/
./ckpt/BiRefNet-general-epoch_244.pth
./config.py
./dataset.py
./evaluation/
./inference.py
./requirements.txt
.
.
Here are the contents of the compressed file. After uploading to the bucket, I tried to load the tar.gz file in the bucket using pytorchmodel in the sagemaker notebook. However, I keep getting an error that inference.py is missing. I tried asking for help from chatgpt and many others, but was unsuccessful. Here is the code I wrote:
import sagemaker
from sagemaker.pytorch import PyTorchModel
sagemaker_session = sagemaker.Session()
role = sagemaker.get_execution_role()
model_data = 's3://sagemaker-birefnet-up/path/to/birefnet.tar.gz'
pytorch_model = PyTorchModel(
model_data=model_data,
role=role,
entry_point='inference.py',
framework_version='2.5.1',
py_version='py311',
sagemaker_session=sagemaker_session
)
predictor = pytorch_model.deploy(
initial_instance_count=1,
instance_type='ml.t2.medium',
)
FileNotFoundError: [Errno 2] No such file or directory: 'inference.py'
What did I do wrong?
I thought what I wanted to do was simple. I tried recompressing and changing the model path, but nothing worked.
Share Improve this question asked Mar 25 at 8:48 dev_seodev_seo 11 Answer
Reset to default 0I think both inference.py
and requirements.txt
should be located in a subfolder named code
, unless you specify a different folder using the parameter source_dir
argument when creating PyTorch estimator.
See here for details.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744208863a4563236.html
评论列表(0条)