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
- 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). - Place it in one of these folders based on difficulty:
beginner_source— beginner levelintermediate_source— intermediate leveladvanced_source— advanced levelrecipes_source— short recipesprototype_source— unstable prototype features
- For non-prototype tutorials, add it to the table of contents (
toctree) and create acustomcarditeminindex.rst. - For non-prototype tutorials, add a thumbnail in
index.rst; for recipes, add one inrecipes_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 todocs/. Takes 60–120 minutes on GPU systems. - Quick preview (
make html-noplot): builds basic HTML to_build/htmlwithout 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 onlypyspelling -n reST—.rstfiles only (currently limited to thebeginner/directory)
License
BSD licensed (see the LICENSE file in the repo).
Related
- Project
- Project
- Project
- Project