Can't load xgboost models created with Sagemaker Estimator

0

Stumbled upon this while trying to evaluate my xgboost model:

model = pickle.load(open("./data/xgboost-model", "rb"))
UnpicklingError: unpickling stack underflow

The model was trained using :

container = image_uris.retrieve(framework='xgboost', region=boto3.Session().region_name, version='1.3-1')

Any ideas on how I can load the model? Thanks.

  • Hi Dani, I'm able to load the XGBoost model trained using a built-in container using the same script you've used above. Can you re-download the pickle file from S3 and try it again? From the error, it looks like it might be an issue with partial file download.

DaniV
질문됨 2년 전883회 조회
1개 답변
1

Hello,

I see that you are using XGBoost version = 1.3-1

Looks like the latest xgboost have changed the way the model is saved or loaded.

If you are using pickle to load the model, then try using the previous version of xgboost, such as 1.2-1, which will get loaded successfully.

https://stackoverflow.com/questions/69099627/what-causes-an-unpickling-stack-underflow-when-trying-to-serialize-a-succesfully

If you would like to use version 1.3-1, you can load it the following way -

=================

import xgboost as xgb

model = xgb.Booster()

model.load_model('xgboost-model')

=================

If you still continue to face the issue, I would recommend you to open a case with AWS Premium Support SageMaker team so that we can discuss more on the use case along with the implementation required for your use case Open a support case with AWS using the link: https://console.aws.amazon.com/support/home?#/case/create

AWS
Bunny
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠