Skip to content

Adding links to recent tutorial pages #489

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

Merged
merged 1 commit into from
Apr 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions intermediate_source/model_parallel_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
*************************************************************
**Author**: `Shen Li <https://mrshenli.github.io/>`_

Data parallel and model parallel are widely-used distributed training
Data parallel and model parallel are widely-used in distributed training
techniques. Previous posts have explained how to use
`DataParallel <https://pytorch.org/tutorials/beginner/blitz/data_parallel_tutorial.html>`_
to train a neural network on multiple GPUs. ``DataParallel`` replicates the
same model to all GPUs, where each GPU consumes a different partition of the
input data. Although it can significantly accelerate the training process, it
does not work for some use cases where the model is large to fit into a single
GPU. This post shows how to solve that problem by using model parallel and also
shares some insights on how to speed up model parallel training.
does not work for some use cases where the model is too large to fit into a
single GPU. This post shows how to solve that problem by using model parallel
and also shares some insights on how to speed up model parallel training.

The high-level idea of model parallel is to place different sub-networks of a
model onto different devices, and implement the ``forward`` method accordingly
Expand All @@ -23,11 +23,21 @@
of model parallel. It is up to the readers to apply the ideas to real-world
applications.

Let us start with a toy model that contains two linear layers. To run this
model on two GPUs, simply put each linear layer on a different GPU, and move
inputs and intermediate outputs to match the layer devices accordingly.
**Recommended Reading:**

- https://pytorch.org/ For installation instructions
- :doc:`/beginner/blitz/data_parallel_tutorial` Single-Machine Data Parallel
- :doc:`/intermediate/ddp_tutorial` Combine Distributed Data Parallel and Model Parallel
"""

######################################################################
# Basic Usage
# =======================
#
# Let us start with a toy model that contains two linear layers. To run this
# model on two GPUs, simply put each linear layer on a different GPU, and move
# inputs and intermediate outputs to match the layer devices accordingly.

import torch
import torch.nn as nn
import torch.optim as optim
Expand Down