question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using dask with PyTorch (train a model)

See original GitHub issue

I find Dask very useful, and would like to use it to accelerate some pytorch models I am working on. A function to be accelerated would be the forward() function. I started doing some tests, but I get errors like these:

  File "/home/muammar/.local/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 81, in serialization_error_loads
    raise TypeError(msg)
TypeError: Could not serialize object of type Tensor.
Traceback (most recent call last):
  File "/home/muammar/.local/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 144, in serialize
    header, frames = dumps(x, context=context) if wants_context else dumps(x)
  File "/home/muammar/.local/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 38, in dask_dumps
    header, frames = dumps(x)
  File "/home/muammar/.local/lib/python3.7/site-packages/distributed/protocol/torch.py", line 10, in serialize_torch_Tensor
    header, frames = serialize(t.numpy())
RuntimeError: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead.

If I detach the variable, then pytorch does not work with numpy arrays. My question would be – what is the state of pytorch support? If it is of any help, I would be more than happy to try any code (or even write something if it is under my capabilities) because it would be very useful to have this support in Dask. Thanks for this great python module.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:48 (43 by maintainers)

github_iconTop GitHub Comments

2reactions
mrocklincommented, Mar 4, 2020

Thank you for thinking of us @muammar . Are you able to share the article?

1reaction
stsievertcommented, Mar 4, 2020

I would like to add you in the acknowledgment section.

@muammar no objections here! Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Training a PyTorch Model across a Dask Cluster | Saturn Cloud
Training a PyTorch model can potentially be sped up dramatically by having the training computations done on multiple GPUs across multiple workers. This...
Read more >
PyTorch — dask-ml 2022.5.28 documentation
Skorch allows PyTorch models to be wrapped in Scikit-learn compatible estimators. So, that means that PyTorch models wrapped in Skorch can be used...
Read more >
Analyzing Microscopy Images with PyTorch and Dask - Coiled
The Batch Prediction with PyTorch tutorial uses dask.delayed. With dask.delayed, functions aren't executed immediately but lazily. The execution ...
Read more >
dask-pytorch-ddp - PyPI
bootstrapping PyTorch workers on top of a Dask cluster · Using distributed data stores (e.g., S3) as normal PyTorch datasets · mechanisms for ......
Read more >
Computer Vision at Scale With Dask And PyTorch - KDnuggets
A tutorial on conducting image classification inference using the Resnet50 deep learning model at scale with using GPU clusters on Saturn ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found