aws-samples / aws-samples/bedrock-multi-agents-collaboration-workshop

Peak Load Manager Traceback Error - [Bug]

Open
#18 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
170
Forks
66
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Traceback occurs in 3_peak_load_manager.jpynb in "Creating Agent"

File numpy[/random/mtrand.pyx:1](https://xzeowhbhon9wxqz.studio.us-west-2.sagemaker.aws/random/mtrand.pyx#line=0), in init numpy.random.mtrand()

ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

**To Reproduce**
Steps to reproduce the behavior (or some version of this):
1. Go to 3_peak_load_manager.jpynb in SageMaker AI Jupyter Notebook
2. Execute sequence of steps waiting for each step to complete
3. Execute step under 'Creating Agent'
4. Task
import boto3
import sagemaker
import os
import json, uuid
import random
import time
sts_client = boto3.client('sts')
boto_session = boto3.session.Session()
region = boto_session.region_name

session = sagemaker.Session()
bucket_name = session.default_bucket()

account_id = sts_client.get_caller_identity()["Account"]

agent_foundation_model = [
'anthropic.claude-3-5-sonnet-20240620-v1:0',
'anthropic.claude-3-sonnet-20240229-v1:0',
'anthropic.claude-3-haiku-20240307-v1:0',
]

---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[6], line 2
1 import boto3
----> 2 import sagemaker
3 import os
4 import json, uuid

File [/opt/conda/lib/python3.11/site-packages/sagemaker/__init__.py:18](https://xzeowhbhon9wxqz.studio.us-west-2.sagemaker.aws/opt/conda/lib/python3.11/site-packages/sagemaker/__init__.py#line=17)
14 from __future__ import absolute_import
16 import importlib_metadata
---> 18 from sagemaker import estimator, parameter, tuner # noqa: F401
19 from sagemaker.amazon.kmeans import KMeans, KMeansModel, KMeansPredictor # noqa: F401
20 from sagemaker.amazon.pca import PCA, PCAModel, PCAPredictor # noqa: F401

File [/opt/conda/lib/python3.11/site-packages/sagemaker/estimator.py:30](https://xzeowhbhon9wxqz.studio.us-west-2.sagemaker.aws/opt/conda/lib/python3.11/site-packages/sagemaker/estimator.py#line=29)
27 from six.moves.urllib.parse import urlparse
29 import sagemaker
---> 30 from sagemaker import git_utils, image_uris, vpc_utils, s3
31 from sagemaker.analytics import TrainingJobAnalytics
32 from sagemaker.config import (
33 ESTIMATOR_DEBUG_HOOK_CONFIG_PATH,
34 TRAINING_JOB_VOLUME_KMS_KEY_ID_PATH,
(...)
42 TRAINING_JOB_INTER_CONTAINER_ENCRYPTION_PATH,
43 )

File [/opt/conda/lib/python3.11/site-packages/sagemaker/image_uris.py:24](https://xzeowhbhon9wxqz.studio.us-west-2.sagemaker.aws/opt/conda/lib/python3.11/site-packages/sagemaker/image_uris.py#line=23)
21 from packaging.version import Version
23 from sagemaker import utils
---> 24 from sagemaker.jumpstart.constants import DEFAULT_JUMPSTART_SAGEMAKER_SESSION, JUMPSTART_LOGGER
25 from sagemaker.jumpstart.enums import JumpStartModelType
26 from sagemaker.jumpstart.utils import is_jumpstart_model_input

File [/opt/conda/lib/python3.11/site-packages/sagemaker/jumpstart/constants.py:19](https://xzeowhbhon9wxqz.studio.us-west-2.sagemaker.aws/opt/conda/lib/python3.11/site-packages/sagemaker/jumpstart/constants.py#line=18)
17 from typing import Dict, Set, Type
18 import boto3
---> 19 from sagemaker.base_deserializers import BaseDeserializer, JSONDeserializer
20 from sagemaker.jumpstart.enums import (
21 JumpStartScriptScope,
22 SerializerType,
(...)
25 JumpStartModelType,
26 )
27 from sagemaker.jumpstart.types import JumpStartLaunchedRegionInfo, JumpStartS3FileType

File [/opt/conda/lib/python3.11/site-packages/sagemaker/base_deserializers.py:30](https://xzeowhbhon9wxqz.studio.us-west-2.sagemaker.aws/opt/conda/lib/python3.11/site-packages/sagemaker/base_deserializers.py#line=29)
27 from sagemaker.utils import DeferredError
29 try:
---> 30 import pandas
31 except ImportError as e:
32 pandas = DeferredError(e)

File [/opt/conda/lib/python3.11/site-packages/pandas/__init__.py:37](https://xzeowhbhon9wxqz.studio.us-west-2.sagemaker.aws/opt/conda/lib/python3.11/site-packages/pandas/__init__.py#line=36)
30 _module = _err.name
31 raise ImportError(
32 f"C extension: {_module} not built. If you want to import "
33 "pandas from the source directory, you may need to run "
34 "'python setup.py build_ext' to build the C extensions first."
35 ) from _err
---> 37 from pandas._config import (
38 get_option,
39 set_option,
40 reset_option,
41 describe_option,
42 option_context,
43 options,
44 )
46 # let init-time option registration happen
47 import pandas.core.config_init # pyright: ignore[reportUnusedImport] # noqa: F401

File [/opt/conda/lib/python3.11/site-packages/pandas/_config/__init__.py:20](https://xzeowhbhon9wxqz.studio.us-west-2.sagemaker.aws/opt/conda/lib/python3.11/site-packages/pandas/_config/__init__.py#line=19)
1 """
2 pandas._config is considered explicitly upstream of everything else in pandas,
3 should have no intra-pandas dependencies.
(...)
6 are initialized.
7 """
8 __all__ = [
9 "config",
10 "detect_console_encoding",
(...)
18 "warn_copy_on_write",
19 ]
---> 20 from pandas._config import config
21 from pandas._config import dates # pyright: ignore[reportUnusedImport] # noqa: F401
22 from pandas._config.config import (
23 _global_config,
24 describe_option,
(...)
29 set_option,
30 )

File [/opt/conda/lib/python3.11/site-packages/pandas/_config/config.py:68](https://xzeowhbhon9wxqz.studio.us-west-2.sagemaker.aws/opt/conda/lib/python3.11/site-packages/pandas/_config/config.py#line=67)
58 from typing import (
59 TYPE_CHECKING,
60 Any,
(...)
64 cast,
65 )
66 import warnings
---> 68 from pandas._typing import (
69 F,
70 T,
71 )
72 from pandas.util._exceptions import find_stack_level
74 if TYPE_CHECKING:

File [/opt/conda/lib/python3.11/site-packages/pandas/_typing.py:198](https://xzeowhbhon9wxqz.studio.us-west-2.sagemaker.aws/opt/conda/lib/python3.11/site-packages/pandas/_typing.py#line=197)
192 Frequency = Union[str, "BaseOffset"]
193 Axes = ListLike
195 RandomState = Union[
196 int,
197 np.ndarray,
--> 198 np.random.Generator,
199 np.random.BitGenerator,
200 np.random.RandomState,
201 ]
203 # dtypes
204 NpDtype = Union[str, np.dtype, type_t[Union[str, complex, bool, object]]]

File [/opt/conda/lib/python3.11/site-packages/numpy/__init__.py:340](https://xzeowhbhon9wxqz.studio.us-west-2.sagemaker.aws/opt/conda/lib/python3.11/site-packages/numpy/__init__.py#line=339), in __getattr__(attr)
336 def __dir__():
337 public_symbols = globals().keys() | {'testing'}
338 public_symbols -= {
339 "core", "matrixlib",
--> 340 # These were moved in 1.25 and may be deprecated eventually:
341 "ModuleDeprecationWarning", "VisibleDeprecationWarning",
342 "ComplexWarning", "TooHardError", "AxisError"
343 }
344 return list(public_symbols)

File [/opt/conda/lib/python3.11/site-packages/numpy/random/__init__.py:180](https://xzeowhbhon9wxqz.studio.us-west-2.sagemaker.aws/opt/conda/lib/python3.11/site-packages/numpy/random/__init__.py#line=179)
126 __all__ = [
127 'beta',
128 'binomial',
(...)
176 'zipf',
177 ]
179 # add these for module-freeze analysis (like PyInstaller)
--> 180 from . import _pickle
181 from . import _common
182 from . import _bounded_integers

File [/opt/conda/lib/python3.11/site-packages/numpy/random/_pickle.py:1](https://xzeowhbhon9wxqz.studio.us-west-2.sagemaker.aws/opt/conda/lib/python3.11/site-packages/numpy/random/_pickle.py#line=0)
----> 1 from .mtrand import RandomState
2 from ._philox import Philox
3 from ._pcg64 import PCG64, PCG64DXSM

File numpy[/random/mtrand.pyx:1](https://xzeowhbhon9wxqz.studio.us-west-2.sagemaker.aws/random/mtrand.pyx#line=0), in init numpy.random.mtrand()

ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

**Expected behavior**
Code expected to execute without error.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**! Additional context !**
- Execution of bedrock-multi-agent-collaboration-workshop in Workshop Studio event

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure in 3_peak_load_manager.jpynb at the "Creating Agent" step, beginning with the import boto3 and import sagemaker cells. Inspect the NumPy and pandas imports involved in the traceback and verify the notebook completes that step without the binary-incompatibility error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, numpy, pandas, python
Domain
ai, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.