pytorch/tutorials

PyTorch tutorials.

What it is

A collection of PyTorch learning materials, published as web documentation at https://pytorch.org/tutorials. The tutorials are written as Python files that get converted into HTML pages, with a Jupyter notebook version automatically generated for each one (runnable in Google Colab).

Where to ask questions

If you have a question about a tutorial, post it on the dev-discuss forum — not as a GitHub issue. The README says you'll get a faster answer there.

How to report issues

Two types of issues are accepted:

  • Feature request — propose a new tutorial. You must explain why it's needed and how it shows PyTorch's value.
  • Bug report — report a broken or outdated tutorial. Include the output of python3 -m torch.utils.collect_env (which gathers info about your system) in the report.

How to contribute a new tutorial

  1. Write a Python file. If you want it executed when inserted into the docs, name it with the suffix tutorial (e.g., your_tutorial.py).
  2. Place it in one of these folders based on difficulty:
    • beginner_source — beginner level
    • intermediate_source — intermediate level
    • advanced_source — advanced level
    • recipes_source — short recipes
    • prototype_source — unstable prototype features
  3. For non-prototype tutorials, add it to the table of contents (toctree) and create a customcarditem in index.rst.
  4. For non-prototype tutorials, add a thumbnail in index.rst; for recipes, add one in recipes_index.rst.

If you start with a Jupyter notebook, there's a linked script to convert it to a Python file. After conversion, check that headings and structure are logical.

Building locally

The full build is large and needs a GPU. Options:

  • Full build (make docs): downloads data, runs the tutorials, builds docs to docs/. Takes 60–120 minutes on GPU systems.
  • Quick preview (make html-noplot): builds basic HTML to _build/html without running the tutorial code — useful if you don't have a GPU.

First install dependencies with pip install -r requirements.txt. You can use conda or virtualenv (the README shows a virtualenv setup).

Building a single tutorial

Set the GALLERY_PATTERN environment variable to a filename (or regex) to build only that tutorial. Example:

GALLERY_PATTERN="neural_style_transfer_tutorial.py" make html

Spell checking

Use pyspelling to catch spelling errors:

  • pyspelling — full check (~3 minutes)
  • pyspelling -n python — Python files only
  • pyspelling -n reST — .rst files only (currently limited to the beginner/ directory)

License

BSD licensed (see the LICENSE file in the repo).

Related

  • Project
  • Project
  • Project
  • Project