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

UserWarning: TypedStorage is deprecated. #6104

Closed
wyli opened this issue Mar 6, 2023 · 0 comments · Fixed by #6105
Closed

UserWarning: TypedStorage is deprecated. #6104

wyli opened this issue Mar 6, 2023 · 0 comments · Fixed by #6105
Labels
bug Something isn't working

Comments

@wyli
Copy link
Contributor

wyli commented Mar 6, 2023

Describe the bug
see also #5862
pytorch docker 23.01

MONAI version: 1.1.0+271.g8deedd61
Numpy version: 1.22.2
Pytorch version: 1.14.0a0+44dac51
MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False
MONAI rev id: 8deedd6
MONAI file: /workspace/MONAI/monai/init.py

root@4242496:/workspace/MONAI# python -W error -m tests.test_meta_tensor
...............................................................................Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/queues.py", line 239, in _feed
    obj = _ForkingPickler.dumps(obj)
  File "/usr/lib/python3.8/multiprocessing/reduction.py", line 51, in dumps
    cls(buf, protocol).dump(obj)
  File "/workspace/MONAI/monai/data/__init__.py", line 132, in reduce_meta_tensor
    storage = meta_tensor.untyped_storage() if hasattr(meta_tensor, "untyped_storage") else meta_tensor.storage()
  File "/usr/local/lib/python3.8/dist-packages/torch/_tensor.py", line 226, in storage
    return handle_torch_function(Tensor.storage, (self,), self)
  File "/usr/local/lib/python3.8/dist-packages/torch/overrides.py", line 1537, in handle_torch_function
    result = torch_func_method(public_api, types, args, kwargs)
  File "/workspace/MONAI/monai/data/meta_tensor.py", line 276, in __torch_function__
    ret = super().__torch_function__(func, types, args, kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/_tensor.py", line 1283, in __torch_function__
    ret = func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/_tensor.py", line 228, in storage
    torch.storage._warn_typed_storage_removal()
  File "/usr/local/lib/python3.8/dist-packages/torch/storage.py", line 315, in _warn_typed_storage_removal
    warnings.warn(message, UserWarning)
UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly.
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/queues.py", line 239, in _feed
    obj = _ForkingPickler.dumps(obj)
  File "/usr/lib/python3.8/multiprocessing/reduction.py", line 51, in dumps
    cls(buf, protocol).dump(obj)
  File "/workspace/MONAI/monai/data/__init__.py", line 132, in reduce_meta_tensor
    storage = meta_tensor.untyped_storage() if hasattr(meta_tensor, "untyped_storage") else meta_tensor.storage()
  File "/usr/local/lib/python3.8/dist-packages/torch/_tensor.py", line 226, in storage
    return handle_torch_function(Tensor.storage, (self,), self)
  File "/usr/local/lib/python3.8/dist-packages/torch/overrides.py", line 1537, in handle_torch_function
    result = torch_func_method(public_api, types, args, kwargs)
  File "/workspace/MONAI/monai/data/meta_tensor.py", line 276, in __torch_function__
    ret = super().__torch_function__(func, types, args, kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/_tensor.py", line 1283, in __torch_function__
    ret = func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/_tensor.py", line 228, in storage
    torch.storage._warn_typed_storage_removal()
  File "/usr/local/lib/python3.8/dist-packages/torch/storage.py", line 315, in _warn_typed_storage_removal
    warnings.warn(message, UserWarning)
UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly.

@wyli wyli added the bug Something isn't working label Mar 6, 2023
@wyli wyli closed this as completed in #6105 Mar 6, 2023
wyli added a commit that referenced this issue Mar 6, 2023
Fixes #6104

### Description

workaround adapted from
https://github.com/pytorch/pytorch/blob/44dac51/torch/_tensor.py#L231-L233

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Wenqi Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant