Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumPy v2 Compatibility #6874

Closed
daskol opened this issue Jun 29, 2024 · 3 comments
Closed

NumPy v2 Compatibility #6874

daskol opened this issue Jun 29, 2024 · 3 comments

Comments

@daskol
Copy link

daskol commented Jun 29, 2024

Missing compatibility with the major NumPy v2 release in the latest tensorboard==2.17.0 version.

    self._output.emit_scalar(
  File "/usr/lib/python3.12/dist-packages/tensorboard/summary/_output.py", line 109, in emit_scalar
    tensor_proto = tensor_util.make_tensor_proto(data)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/dist-packages/tensorboard/util/tensor_util.py", line 405, in make_tensor_proto
    numpy_dtype = dtypes.as_dtype(nparray.dtype)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py", line 677, in as_dtype
    if type_value.type == np.string_ or type_value.type == np.unicode_:
                          ^^^^^^^^^^
  File "/usr/lib/python3.12/dist-packages/numpy/__init__.py", line 397, in __getattr__
    raise AttributeError(
AttributeError: `np.string_` was removed in the NumPy 2.0 release. Use `np.bytes_` instead.. Did you mean: 'strings'?
@daskol
Copy link
Author

daskol commented Jul 1, 2024

@yatbear Hot-fix is here.

--- a/tensorboard/compat/tensorflow_stub/dtypes.py	2024-06-30 15:59:21.290476559 +0300
+++ b/tensorboard/compat/tensorflow_stub/dtypes.py	2024-06-30 15:59:29.377199428 +0300
@@ -674,7 +674,7 @@
         # dtype with a single constant (np.string does not exist) to decide
         # dtype is a "string" type. We need to compare the dtype.type to be
         # sure it's a string type.
-        if type_value.type == np.string_ or type_value.type == np.unicode_:
+        if type_value.type == np.bytes_ or type_value.type == np.str_:
             return string
 
     if isinstance(type_value, (type, np.dtype)):
--- a/tensorboard/util/tensor_util.py	2024-06-30 15:58:32.200133798 +0300
+++ b/tensorboard/util/tensor_util.py	2024-06-30 15:58:50.533595467 +0300
@@ -137,7 +137,7 @@
     # dtype with a single constant (np.string does not exist) to decide
     # dtype is a "string" type. We need to compare the dtype.type to be
     # sure it's a string type.
-    if dtype.type == np.string_ or dtype.type == np.unicode_:
+    if dtype.type == np.bytes_ or dtype.type == np.str_:
         return SlowAppendObjectArrayToTensorProto
     return GetFromNumpyDTypeDict(_NP_TO_APPEND_FN, dtype)
 

@yatbear
Copy link
Member

yatbear commented Jul 1, 2024

@daskol Thanks! The fix was merged at #6871 and it should be included in the latest tensorboard nightly.

@daskol
Copy link
Author

daskol commented Jul 1, 2024

Great! I've search for similar existing issue but found nothing.

@daskol daskol closed this as completed Jul 1, 2024
j3soon added a commit to j3soon/tbparse that referenced this issue Aug 13, 2024
This is a temporary requirement and should be removed after the tensorboard 2.17.1 release.

References:
- tensorflow/tensorboard#6871
- tensorflow/tensorboard#6874
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants