All the tutorials are now presented as sphinx style documentation at:
If you have a question about a tutorial, post in https://dev-discuss.pytorch.org/ rather than creating an issue in this repo. Your question will be answered much faster on the dev-discuss forum.
You can submit the following types of issues:
python3 -m torch.utils.collect_env
to get information about your environment and add the output to the bug report.We use sphinx-gallery's notebook styled examples to create the tutorials. Syntax is very simple. In essence, you write a slightly well formatted Python file and it shows up as an HTML page. In addition, a Jupyter notebook is autogenerated and available to run in Google Colab.
Here is how you can create a new tutorial (for a detailed description, see CONTRIBUTING.md):
tutorial
so that the file name is your_tutorial.py
.beginner_source
, intermediate_source
, advanced_source
directory based on the level of difficulty. If it is a recipe, add it to recipes_source
. For tutorials demonstrating unstable prototype features, add to the prototype_source
.toctree
directive and create a customcarditem
in index.rst... customcarditem:: beginner/your_tutorial.html
. For Recipes, create a thumbnail in the recipes_index.rstIf you are starting off with a Jupyter notebook, you can use this script to convert the notebook to Python file. After conversion and addition to the project, please make sure that section headings and other things are in logical order.
The tutorial build is very large and requires a GPU. If your machine does not have a GPU device, you can preview your HTML build without actually downloading the data and running the tutorial code:
pip install -r requirements.txt
.Typically, you would run either in
conda
orvirtualenv
. If you want to usevirtualenv
, in the root of the repo, run:virtualenv venv
, thensource venv/bin/activate
.
make docs
. This will download the data, execute the tutorials and build the documentation to docs/
directory. This might take about 60-120 min for systems with GPUs. If you do not have a GPU installed on your system, then see next step.make html-noplot
to build basic html documentation to _build/html
. This way, you can quickly preview your tutorial.If you get ModuleNotFoundError: No module named 'pytorch_sphinx_theme' make: * [html-noplot] Error 2 from /tutorials/src/pytorch-sphinx-theme or /venv/src/pytorch-sphinx-theme (while using virtualenv), run
python setup.py install
.
You can build a single tutorial by using the GALLERY_PATTERN
environment variable. For example to run only neural_style_transfer_tutorial.py
, run:
GALLERY_PATTERN="neural_style_transfer_tutorial.py" make html
or
GALLERY_PATTERN="neural_style_transfer_tutorial.py" sphinx-build . _build
The GALLERY_PATTERN
variable respects regular expressions.
PyTorch Tutorials is BSD licensed, as found in the LICENSE file.
BSD 3-Clause License
Copyright (c) 2017-2022, Pytorch contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.