Accessing PyTorch documentation offline

Is there a way for me to access PyTorch documentation offline? I checked the github repo and there seems to be a doc folder but I am not clear on how to generate the documentation so that I can use it offline.
I am looking for documentation for stable 0.4.0.

2 Likes

Hi,

The doc needs to be generated from the source code.
To get it you will need to go into the docs folder and then run make (or the bat file if you’re on windows). You might need to install the dependencies in the requirements.txt file before.
Once make run, you will have a local html file that you can browse offfline containing all the doc.

5 Likes

Thanks. I was able to generate the documentation in html format using the steps you mentioned. Any idea how I can generate the docs specific to 0.4.0 stable? The generated docs show unstable 0.3.0.post4. I tried checking out to tag v0.4.0 in repo, but it still generates the unstable docs.

The version number might not be correct. Because the build system for the releases is reponsible for setting the versions to something else than “unstable”.
It will generate the doc for the current version of the repo. So if you’re at tag 0.4.0, it will generate the doc for this version.

Thanks for clarifying.

It would be quite handy to have conda packages with the documentation though.

1 Like

Hi, but how can I run the Makefile in some specific folder? I want to install the docs only.

how to install the dependencies in the requirements.txt

sh ./Makefile
./Makefile: 5: ./Makefile: SPHINXOPTS: not found
./Makefile: 6: ./Makefile: SPHINXBUILD: not found
./Makefile: 7: ./Makefile: SPHINXPROJ: not found
./Makefile: 8: ./Makefile: SOURCEDIR: not found
./Makefile: 9: ./Makefile: BUILDDIR: not found
./Makefile: 10: ./Makefile: PYCMD: not found
./Makefile: 13: ./Makefile: help:: not found
./Makefile: 14: ./Makefile: SPHINXBUILD: not found
./Makefile: 14: ./Makefile: SOURCEDIR: not found
./Makefile: 14: ./Makefile: BUILDDIR: not found
./Makefile: 14: ./Makefile: SPHINXOPTS: not found
./Makefile: 14: ./Makefile: O: not found
./Makefile: 14: ./Makefile: @: not found
./Makefile: 16: ./Makefile: figures:: not found
./Makefile: 17: ./Makefile: PYCMD: not found
./Makefile: 17: ./Makefile: @: not found
./Makefile: 19: ./Makefile: docset:: not found
./Makefile: 20: ./Makefile: SPHINXPROJ: not found
./Makefile: 20: ./Makefile: SOURCEDIR: not found
./Makefile: 20: ./Makefile: BUILDDIR: not found
./Makefile: 20: ./Makefile: doc2dash: not found
./Makefile: 23: ./Makefile: SPHINXPROJ: not found
./Makefile: 23: ./Makefile: SPHINXPROJ: not found
cp: cannot stat '.docset/icon.png': No such file or directory
./Makefile: 24: ./Makefile: SPHINXPROJ: not found
./Makefile: 24: ./Makefile: SPHINXPROJ: not found
convert: unable to open image `.docset/icon@2x.png': No such file or directory @ error/blob.c/OpenBlob/2712.
convert: no images defined `.docset/icon.png' @ error/convert.c/ConvertImageCommand/3210.
./Makefile: 26: ./Makefile: html-stable:: not found
Traceback (most recent call last):
  File "source/scripts/build_activation_images.py", line 67, in <module>
    function = torch.nn.modules.activation.__dict__[function_name]()
KeyError: 'CELU'
Makefile:17: recipe for target 'figures' failed
make: *** [figures] Error 1
./Makefile: 33: ./Makefile: .PHONY:: not found
./Makefile: 37: ./Makefile: %:: not found
./Makefile: 38: ./Makefile: SPHINXBUILD: not found
./Makefile: 38: ./Makefile: SOURCEDIR: not found
./Makefile: 38: ./Makefile: BUILDDIR: not found
./Makefile: 38: ./Makefile: SPHINXOPTS: not found
./Makefile: 38: ./Makefile: O: not found
./Makefile: 38: ./Makefile: @: not found
./Makefile: 40: ./Makefile: clean:: not found
./Makefile: 41: ./Makefile: @echo: not found
./Makefile: 42: ./Makefile: BUILDDIR: not found
./Makefile: 42: ./Makefile: BUILDDIR: not found
./Makefile: 42: ./Makefile: @rm: not found

You’re note suppose to execute a Makefile with bash. Just run make in the folder where the Makefile is.

Thank you for your Replay. But I still got the issue.

Not working for me in May 2021

ARNING: autodoc: failed to import class ‘ConvReLU3d’ from module ‘torch.nn.intrinsic.qat’; the following exception was raised:
Traceback (most recent call last):
File “c:\python38\lib\site-packages\sphinx\util\inspect.py”, line 403, in safe_getattr
return getattr(obj, name, *defargs)
AttributeError: module ‘torch.nn.intrinsic.qat’ has no attribute ‘ConvReLU3d’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “c:\python38\lib\site-packages\sphinx\ext\autodoc\importer.py”, line 111, in import_object
obj = attrgetter(obj, mangled_name)
File “c:\python38\lib\site-packages\sphinx\ext\autodoc_init_.py”, line 320, in get_attr
return autodoc_attrgetter(self.env.app, obj, name, *defargs)
File “c:\python38\lib\site-packages\sphinx\ext\autodoc_init_.py”, line 2604, in autodoc_attrgetter
return safe_getattr(obj, name, *defargs)
File “c:\python38\lib\site-packages\sphinx\util\inspect.py”, line 419, in safe_getattr
raise AttributeError(name) from exc
AttributeError: ConvReLU3d

c:\python38\lib\site-packages\torch\nn\quantized\modules\activation.py:docstring of torch.nn.quantized.modules.activation.ReLU6:14: WARNING: image file not readable: scripts/activation_images/ReLU6.png
looking for now-outdated files… none found
pickling environment… done
checking consistency… done
preparing documents… done
writing output… [ 0%] complex_numbers
Exception occurred:
File “c:\python38\lib\subprocess.py”, line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
The full traceback has been saved in C:\Users\paulb\AppData\Local\Temp\sphinx-err-nxayl6xl.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at https://github.com/sphinx-doc/sphinx/issues. Thanks!

Hi,

We build the doc on linux machines all the time I’m afraid. It might be possible that it is not working on Windows :confused:
Do you have a linux machine you can use to get the doc by any chance?

Another convoluted way to do this is to download it directly from our build.
On every PR (pick one randomly on pytorch github), there is a pytorch_python_doc_build that actually builds the doc. You can check there the artifact page that contains the full doc: https://app.circleci.com/pipelines/github/pytorch/pytorch/326575/workflows/30cd30c4-fea5-4165-ab08-a54b85d0e67e/jobs/13676034/artifacts
You can download all of these as a single file by using circle CI API directly: Storing Build Artifacts - CircleCI