admin管理员组文章数量:1399926
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.
本文标签: amazon web servicestargz file in s3 bucket is not loaded in sagemaker notebookStack Overflow
版权声明:本文标题:amazon web services - tar.gz file in s3 bucket is not loaded in sagemaker notebook - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744208863a2595321.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论