Serialization of torch tensors in GPU memory fails
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 778
- Avg merge
- 2h 50m
- Merged PRs (30d)
- 3
Description
```python
File ".../site-packages/distributed/protocol/serialize.py", line 350, in serialize
header, frames = dumps(x, context=context) if wants_context else dumps(x)
File ".../site-packages/distributed/protocol/serialize.py", line 47, in dask_dumps
sub_header, frames = dumps(x)
File ".../site-packages/distributed/protocol/torch.py", line 21, in serialize_torch_Tensor
sub_header, frames = serialize(t.numpy())
TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
```
https://github.com/dask/distributed/blob/8e3e0f6e7483f4c5ea52221433bd7c618bec7aa7/distributed/protocol/torch.py#L21
The solution could be to `t.cpu().numpy()` and ensure that the header info is being derived from the tensor before the copy.
However I do not understand the broader repercussions of this change and wanted to confirm if anything else had to be considered ?
--------------------------------------------------------------
NOT A CONTRIBUTION
Contributor guide
Assessment
This issue has not been assessed yet.