# Multi-machine inference with PyTorch

**URL:** <https://discuss.pytorch.org/t/multi-machine-inference-with-pytorch/70354>\
**Category:** distributed\
**Created:** [February 19, 2020, 5:03pm UTC](https://discuss.pytorch.org/t/multi-machine-inference-with-pytorch/70354 "2020-02-19T17:03:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luan\_Goncalves](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/luan_goncalves/32/20734_2.png) [@Luan\_Goncalves](https://discuss.pytorch.org/u/Luan_Goncalves)\
**Post date:** [February 19, 2020, 5:03pm UTC](https://discuss.pytorch.org/t/multi-machine-inference-with-pytorch/70354/1 "2020-02-19T17:03:40Z")

</div>

Hi, I’m new to distributed computation on PyTorch.  
I’m interested in perform a network partitioning so one piece of the network will run on the machine A and the other piece of the network will run on the machine B. The first thing I need to do is to send tensors from machine A to machine B.  
So I thought about use the point-to-point communication as in [Writing Distributed Applications with PyTorch](https://pytorch.org/tutorials/intermediate/dist_tuto.html). I’m trying to adapt this code to send messages between the machines A and B but I have not been well succeed. Can anyone explain the whole pipeline for this?  
Any help would be appreciated!

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [February 20, 2020, 2:28am UTC](https://discuss.pytorch.org/t/multi-machine-inference-with-pytorch/70354/2 "2020-02-20T02:28:02Z")

</div>

If you want to use model sharding, [this simple example](https://discuss.pytorch.org/t/split-single-model-in-multiple-gpus/13239/2) might be useful.  
The linked tutorial explains a distributed setup, so let me know, if I misunderstood your use case.

---

<div class="post-metadata">

**Author:** ![Luan\_Goncalves](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/luan_goncalves/32/20734_2.png) [@Luan\_Goncalves](https://discuss.pytorch.org/u/Luan_Goncalves)\
**Post date:** [February 20, 2020, 12:24pm UTC](https://discuss.pytorch.org/t/multi-machine-inference-with-pytorch/70354/3 "2020-02-20T12:24:26Z")

</div>

First of all, thanks for your attention.  
It is not exactly what I need but it helped me in another point. So thanks again.  
My issue is related to edge computing. Basically I need to run just a couple of layers in a Drone and the other layers will run in a machine equipped with a GPU.  
So i thought that i could send messages from Drone to my machine.  
It is possible to be made with PyTorch?

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [February 21, 2020, 6:19am UTC](https://discuss.pytorch.org/t/multi-machine-inference-with-pytorch/70354/4 "2020-02-21T06:19:43Z")

</div>

That’s a really interesting use case, but I’m not really sure, how well this would work.  
You could most likely connect the drone and your workstation to the same network and use DDP indeed.  
However, have you thought about the latency this would create?  
How long can you wait for the response?

---

<div class="post-metadata">

**Author:** ![Luan\_Goncalves](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/luan_goncalves/32/20734_2.png) [@Luan\_Goncalves](https://discuss.pytorch.org/u/Luan_Goncalves)\
**Post date:** [February 27, 2020, 12:46pm UTC](https://discuss.pytorch.org/t/multi-machine-inference-with-pytorch/70354/5 "2020-02-27T12:46:47Z")

</div>

Yes! You are right.  
Actually, I am interested on measuring this kind of problems because my research is concerned on 5G systems.

---

<div class="post-metadata">

**Author:** ![osalpekar](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/o/5f9b8f/32.png) [@osalpekar](https://discuss.pytorch.org/u/osalpekar)\
**Post date:** [February 27, 2020, 6:29pm UTC](https://discuss.pytorch.org/t/multi-machine-inference-with-pytorch/70354/6 "2020-02-27T18:29:40Z")

</div>

I think what you may be looking for is our Distributed RPC framework ([https://pytorch.org/tutorials/intermediate/rpc\_tutorial.html?highlight=rpc](https://pytorch.org/tutorials/intermediate/rpc_tutorial.html?highlight=rpc)), which allows you to send messages and tensors between workers. Also see the Distributed Autograd Framework ([https://pytorch.org/docs/master/rpc.html#distributed-autograd-framework](https://pytorch.org/docs/master/rpc.html#distributed-autograd-framework)) for training models that are partitioned across machines. Lastly, here is an example of training an RNN using RPC/Distributed Autograd: [https://github.com/pytorch/examples/tree/master/distributed/rpc/rnn](https://github.com/pytorch/examples/tree/master/distributed/rpc/rnn).

---

<div class="post-metadata">

**Author:** ![Luan\_Goncalves](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/luan_goncalves/32/20734_2.png) [@Luan\_Goncalves](https://discuss.pytorch.org/u/Luan_Goncalves)\
**Post date:** [March 2, 2020, 12:08pm UTC](https://discuss.pytorch.org/t/multi-machine-inference-with-pytorch/70354/7 "2020-03-02T12:08:44Z")

</div>

Thanks @osalpekar! It helped me a lot.  
Actually, I want to thank you both for your attention.
