Skip to content

bug: Bentoml Pytorch model serve bug #5365

@Shayantan1012

Description

@Shayantan1012

Describe the bug

C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\io.py:7: BentoMLDeprecationWarning: bentoml.io is deprecated since BentoML v1.4 and will be removed in a future version. Please upgrade to new style IO types instead.   
  warn_deprecated(
C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\Xray\ml\model\model_service.py:11: BentoMLDeprecationWarning: bentoml.pytorch is deprecated since v1.4 and will be removed in a future version.
  bento_model = bentoml.pytorch.get(BENTOML_MODEL_NAME)
C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\models\model.py:354: BentoMLDeprecationWarning: Runner is deprecated since BentoML v1.4 and will be removed in a future version. Please upgrade to new style services.
  return Runner(
C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\Xray\ml\model\model_service.py:15: BentoMLDeprecationWarning: bentoml.Service is deprecated since BentoML v1.4 and will be removed in a future version. Please upgrade to @bentoml.service().
  svc = bentoml.Service(name=BENTOML_SERVICE_NAME, runners=[runner])
Loaded model: Model(tag="xray_model:evviuwztuohmoaav")
Custom objects: {'xray_train_transforms': Compose(
    Resize(size=224, interpolation=bilinear, max_size=None, antialias=True)
    CenterCrop(size=(224, 224))
    ColorJitter(brightness=(0.9, 1.1), contrast=(0.9, 1.1), saturation=(0.9, 1.1), hue=(-0.1, 0.1))
    RandomHorizontalFlip(p=0.5)
    RandomRotation(degrees=[-10.0, 10.0], interpolation=nearest, expand=False, fill=0)
    ToTensor()
    Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
)}
Transform key found: True
2025-05-18T11:25:11+0530 [ERROR] [runner:xray_model:1] An exception occurred while instantiating runner 'xray_model', see details below:
2025-05-18T11:25:11+0530 [ERROR] [runner:xray_model:1] Traceback (most recent call last):
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 313, in init_local
    self._set_handle(LocalRunnerRef)
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 155, in _set_handle
    runner_handle = handle_class(self, *args, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\runner\runner_handle\local.py", line 27, in __init_
    self._runnable = runner.runnable_class(**runner.runnable_init_params)  # type: ignore
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\frameworks\common\pytorch.py", line 52, in __init_
    functools.partial(cls._init_, *args, **kwargs)(
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\frameworks\common\pytorch.py", line 76, in __init_
    self.model: ModelType = loader(bento_model, device_id=self.device_id)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\frameworks\pytorch.py", line 81, in load_model
    model: "torch.nn.Module" = torch.load(
                               ^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\torch\serialization.py", line 1524, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.
        (1) In PyTorch 2.6, we changed the default value of the weights_only argument in torch.load from False to True. Re-running torch.load with weights_only set to False will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
        (2) Alternatively, to load with weights_only=True please check the recommended steps in the following error message.  
        WeightsUnpickler error: Unsupported global: GLOBAL Xray.ml.model.arch.Net was not an allowed global by default. Please use torch.serialization.add_safe_globals([Xray.ml.model.arch.Net]) or the torch.serialization.safe_globals([Xray.ml.model.arch.Net]) context manager to allowlist this global if you trust this class/function.

Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.

2025-05-18T11:25:11+0530 [ERROR] [runner:xray_model:1] Traceback (most recent call last):
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\starlette\routing.py", line 692, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "C:\Program Files\Python312\Lib\contextlib.py", line 210, in _aenter_
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\server\base_app.py", line 74, in lifespan
    ret = on_startup(app)
          ^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\utils\init_.py", line 460, in wrapper
    return func()
           ^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 323, in init_local
    raise e
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 313, in init_local
    self._set_handle(LocalRunnerRef)
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 155, in _set_handle
    runner_handle = handle_class(self, *args, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\runner\runner_handle\local.py", line 27, in __init_
    self._runnable = runner.runnable_class(**runner.runnable_init_params)  # type: ignore
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\frameworks\common\pytorch.py", line 52, in __init_
    functools.partial(cls._init_, *args, **kwargs)(
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\frameworks\common\pytorch.py", line 76, in __init_
    self.model: ModelType = loader(bento_model, device_id=self.device_id)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\frameworks\pytorch.py", line 81, in load_model
    model: "torch.nn.Module" = torch.load(
                               ^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\torch\serialization.py", line 1524, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.
        (1) In PyTorch 2.6, we changed the default value of the weights_only argument in torch.load from False to True. Re-running torch.load with weights_only set to False will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
        (2) Alternatively, to load with weights_only=True please check the recommended steps in the following error message.  
        WeightsUnpickler error: Unsupported global: GLOBAL Xray.ml.model.arch.Net was not an allowed global by default. Please use torch.serialization.add_safe_globals([Xray.ml.model.arch.Net]) or the torch.serialization.safe_globals([Xray.ml.model.arch.Net]) context manager to allowlist this global if you trust this class/function.

Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.

2025-05-18T11:25:11+0530 [ERROR] [runner:xray_model:1] Traceback (most recent call last):
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\starlette\routing.py", line 692, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "C:\Program Files\Python312\Lib\contextlib.py", line 210, in _aenter_
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\server\base_app.py", line 74, in lifespan
    ret = on_startup(app)
          ^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\utils\init_.py", line 460, in wrapper
    return func()
           ^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 323, in init_local
    raise e
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 313, in init_local
    self._set_handle(LocalRunnerRef)
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 155, in _set_handle
    runner_handle = handle_class(self, *args, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\runner\runner_handle\local.py", line 27, in __init_
    self._runnable = runner.runnable_class(**runner.runnable_init_params)  # type: ignore
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\frameworks\common\pytorch.py", line 52, in __init_
    functools.partial(cls._init_, *args, **kwargs)(
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\frameworks\common\pytorch.py", line 76, in __init_
    self.model: ModelType = loader(bento_model, device_id=self.device_id)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\frameworks\pytorch.py", line 81, in load_model
    model: "torch.nn.Module" = torch.load(
                               ^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\torch\serialization.py", line 1524, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.
        (1) In PyTorch 2.6, we changed the default value of the weights_only argument in torch.load from False to True. Re-running torch.load with weights_only set to False will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
        (2) Alternatively, to load with weights_only=True please check the recommended steps in the following error message.  
        WeightsUnpickler error: Unsupported global: GLOBAL Xray.ml.model.arch.Net was not an allowed global by default. Please use torch.serialization.add_safe_globals([Xray.ml.model.arch.Net]) or the torch.serialization.safe_globals([Xray.ml.model.arch.Net]) context manager to allowlist this global if you trust this class/function.

Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.

2025-05-18T11:25:11+0530 [ERROR] [runner:xray_model:1] Application startup failed. Exiting.
2025-05-18T11:25:11+0530 [ERROR] [runner:xray_model:1] Application startup failed. Exiting.
-----------------------------------------------------------------------
C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\io.py:7: BentoMLDeprecationWarning: bentoml.io is deprecated since BentoML v1.4 and will be removed in a future version. Please upgrade to new style IO types instead.   
  warn_deprecated(
C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\Xray\ml\model\model_service.py:11: BentoMLDeprecationWarning: bentoml.pytorch is deprecated since v1.4 and will be removed in a future version.
  bento_model = bentoml.pytorch.get(BENTOML_MODEL_NAME)
C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\models\model.py:354: BentoMLDeprecationWarning: Runner is deprecated since BentoML v1.4 and will be removed in a future version. Please upgrade to new style services.
  return Runner(
C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\Xray\ml\model\model_service.py:15: BentoMLDeprecationWarning: bentoml.Service is deprecated since BentoML v1.4 and will be removed in a future version. Please upgrade to @bentoml.service().
  svc = bentoml.Service(name=BENTOML_SERVICE_NAME, runners=[runner])
Loaded model: Model(tag="xray_model:evviuwztuohmoaav")
Custom objects: {'xray_train_transforms': Compose(
    Resize(size=224, interpolation=bilinear, max_size=None, antialias=True)
    CenterCrop(size=(224, 224))
    ColorJitter(brightness=(0.9, 1.1), contrast=(0.9, 1.1), saturation=(0.9, 1.1), hue=(-0.1, 0.1))
    RandomHorizontalFlip(p=0.5)
    RandomRotation(degrees=[-10.0, 10.0], interpolation=nearest, expand=False, fill=0)
    ToTensor()
    Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
)}
Transform key found: True
2025-05-18T11:25:21+0530 [ERROR] [runner:xray_model:1] An exception occurred while instantiating runner 'xray_model', see details below:
2025-05-18T11:25:21+0530 [ERROR] [runner:xray_model:1] Traceback (most recent call last):
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 313, in init_local
    self._set_handle(LocalRunnerRef)
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 155, in _set_handle
    runner_handle = handle_class(self, *args, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\runner\runner_handle\local.py", line 27, in __init_
    self._runnable = runner.runnable_class(**runner.runnable_init_params)  # type: ignore
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\frameworks\common\pytorch.py", line 52, in __init_
    functools.partial(cls._init_, *args, **kwargs)(
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\frameworks\common\pytorch.py", line 76, in __init_
    self.model: ModelType = loader(bento_model, device_id=self.device_id)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\frameworks\pytorch.py", line 81, in load_model
    model: "torch.nn.Module" = torch.load(
                               ^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\torch\serialization.py", line 1524, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.
        (1) In PyTorch 2.6, we changed the default value of the weights_only argument in torch.load from False to True. Re-running torch.load with weights_only set to False will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
        (2) Alternatively, to load with weights_only=True please check the recommended steps in the following error message.  
        WeightsUnpickler error: Unsupported global: GLOBAL Xray.ml.model.arch.Net was not an allowed global by default. Please use torch.serialization.add_safe_globals([Xray.ml.model.arch.Net]) or the torch.serialization.safe_globals([Xray.ml.model.arch.Net]) context manager to allowlist this global if you trust this class/function.

Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.

2025-05-18T11:25:21+0530 [ERROR] [runner:xray_model:1] Traceback (most recent call last):
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\starlette\routing.py", line 692, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "C:\Program Files\Python312\Lib\contextlib.py", line 210, in _aenter_
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\server\base_app.py", line 74, in lifespan
    ret = on_startup(app)
          ^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\utils\init_.py", line 460, in wrapper
    return func()
           ^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 323, in init_local
    raise e
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 313, in init_local
    self._set_handle(LocalRunnerRef)
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 155, in _set_handle
    runner_handle = handle_class(self, *args, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\runner\runner_handle\local.py", line 27, in __init_
    self._runnable = runner.runnable_class(**runner.runnable_init_params)  # type: ignore
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\frameworks\common\pytorch.py", line 52, in __init_
    functools.partial(cls._init_, *args, **kwargs)(
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\frameworks\common\pytorch.py", line 76, in __init_
    self.model: ModelType = loader(bento_model, device_id=self.device_id)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\frameworks\pytorch.py", line 81, in load_model
    model: "torch.nn.Module" = torch.load(
                               ^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\torch\serialization.py", line 1524, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.
        (1) In PyTorch 2.6, we changed the default value of the weights_only argument in torch.load from False to True. Re-running torch.load with weights_only set to False will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
        (2) Alternatively, to load with weights_only=True please check the recommended steps in the following error message.  
        WeightsUnpickler error: Unsupported global: GLOBAL Xray.ml.model.arch.Net was not an allowed global by default. Please use torch.serialization.add_safe_globals([Xray.ml.model.arch.Net]) or the torch.serialization.safe_globals([Xray.ml.model.arch.Net]) context manager to allowlist this global if you trust this class/function.

Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.

2025-05-18T11:25:21+0530 [ERROR] [runner:xray_model:1] Traceback (most recent call last):
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\starlette\routing.py", line 692, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "C:\Program Files\Python312\Lib\contextlib.py", line 210, in _aenter_
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\server\base_app.py", line 74, in lifespan
    ret = on_startup(app)
          ^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\utils\init_.py", line 460, in wrapper
    return func()
           ^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 323, in init_local
    raise e
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 313, in init_local
    self._set_handle(LocalRunnerRef)
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\runner\runner.py", line 155, in _set_handle
    runner_handle = handle_class(self, *args, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\runner\runner_handle\local.py", line 27, in __init_
    self._runnable = runner.runnable_class(**runner.runnable_init_params)  # type: ignore
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\frameworks\common\pytorch.py", line 52, in __init_
    functools.partial(cls._init_, *args, **kwargs)(
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\internal\frameworks\common\pytorch.py", line 76, in __init_
    self.model: ModelType = loader(bento_model, device_id=self.device_id)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\bentoml\_internal\frameworks\pytorch.py", line 81, in load_model
    model: "torch.nn.Module" = torch.load(
                               ^^^^^^^^^^^
  File "C:\Users\SHAYANTAN BISWAS\Desktop\DeepLearningProject\venv\Lib\site-packages\torch\serialization.py", line 1524, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.
        (1) In PyTorch 2.6, we changed the default value of the weights_only argument in torch.load from False to True. Re-running torch.load with weights_only set to False will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
        (2) Alternatively, to load with weights_only=True please check the recommended steps in the following error message.  
        WeightsUnpickler error: Unsupported global: GLOBAL Xray.ml.model.arch.Net was not an allowed global by default. Please use torch.serialization.add_safe_globals([Xray.ml.model.arch.Net]) or the torch.serialization.safe_globals([Xray.ml.model.arch.Net]) context manager to allowlist this global if you trust this class/function.

Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.

To reproduce

No response

Expected behavior

No response

Environment

service: "Xray.ml.model.model_service:svc"
labels:
    owner: Shayantan Biswas
    stage: dev
include:
    - "Xray/ml/model/model_service.py"
    - "Xray/constant/TrainingPipeline/__init__.py"
python:
    packages:
        - torch
        - torchvision
        - Pillow
        - numpy
    extra_index_url:
        - "https://download.pytorch.org/whl/cpu"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions