METADATA 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. Metadata-Version: 2.1
  2. Name: torch
  3. Version: 2.11.0+cpu
  4. Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
  5. Author-email: PyTorch Team <packages@pytorch.org>
  6. License: BSD-3-Clause
  7. Project-URL: Homepage, https://pytorch.org
  8. Project-URL: Repository, https://github.com/pytorch/pytorch
  9. Project-URL: Documentation, https://pytorch.org/docs
  10. Project-URL: Issue Tracker, https://github.com/pytorch/pytorch/issues
  11. Project-URL: Forum, https://discuss.pytorch.org
  12. Keywords: pytorch,machine learning
  13. Classifier: Development Status :: 5 - Production/Stable
  14. Classifier: Intended Audience :: Developers
  15. Classifier: Intended Audience :: Education
  16. Classifier: Intended Audience :: Science/Research
  17. Classifier: Topic :: Scientific/Engineering
  18. Classifier: Topic :: Scientific/Engineering :: Mathematics
  19. Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
  20. Classifier: Topic :: Software Development
  21. Classifier: Topic :: Software Development :: Libraries
  22. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  23. Classifier: Programming Language :: C++
  24. Classifier: Programming Language :: Python :: 3 :: Only
  25. Classifier: Programming Language :: Python :: 3.10
  26. Classifier: Programming Language :: Python :: 3.11
  27. Classifier: Programming Language :: Python :: 3.12
  28. Classifier: Programming Language :: Python :: 3.13
  29. Classifier: Programming Language :: Python :: 3.14
  30. Requires-Python: >=3.10
  31. Description-Content-Type: text/markdown
  32. License-File: LICENSE
  33. License-File: NOTICE
  34. Requires-Dist: filelock
  35. Requires-Dist: typing-extensions>=4.10.0
  36. Requires-Dist: setuptools<82
  37. Requires-Dist: sympy>=1.13.3
  38. Requires-Dist: networkx>=2.5.1
  39. Requires-Dist: jinja2
  40. Requires-Dist: fsspec>=0.8.5
  41. Provides-Extra: opt-einsum
  42. Requires-Dist: opt-einsum>=3.3; extra == "opt-einsum"
  43. Provides-Extra: optree
  44. Requires-Dist: optree>=0.13.0; extra == "optree"
  45. Provides-Extra: pyyaml
  46. Requires-Dist: pyyaml; extra == "pyyaml"
  47. ![PyTorch Logo](https://github.com/pytorch/pytorch/raw/main/docs/source/_static/img/pytorch-logo-dark.png)
  48. --------------------------------------------------------------------------------
  49. PyTorch is a Python package that provides two high-level features:
  50. - Tensor computation (like NumPy) with strong GPU acceleration
  51. - Deep neural networks built on a tape-based autograd system
  52. You can reuse your favorite Python packages such as NumPy, SciPy, and Cython to extend PyTorch when needed.
  53. Our trunk health (Continuous Integration signals) can be found at [hud.pytorch.org](https://hud.pytorch.org/ci/pytorch/pytorch/main).
  54. <!-- toc -->
  55. - [More About PyTorch](#more-about-pytorch)
  56. - [A GPU-Ready Tensor Library](#a-gpu-ready-tensor-library)
  57. - [Dynamic Neural Networks: Tape-Based Autograd](#dynamic-neural-networks-tape-based-autograd)
  58. - [Python First](#python-first)
  59. - [Imperative Experiences](#imperative-experiences)
  60. - [Fast and Lean](#fast-and-lean)
  61. - [Extensions Without Pain](#extensions-without-pain)
  62. - [Installation](#installation)
  63. - [Binaries](#binaries)
  64. - [NVIDIA Jetson Platforms](#nvidia-jetson-platforms)
  65. - [From Source](#from-source)
  66. - [Prerequisites](#prerequisites)
  67. - [NVIDIA CUDA Support](#nvidia-cuda-support)
  68. - [AMD ROCm Support](#amd-rocm-support)
  69. - [Intel GPU Support](#intel-gpu-support)
  70. - [Get the PyTorch Source](#get-the-pytorch-source)
  71. - [Install Dependencies](#install-dependencies)
  72. - [Install PyTorch](#install-pytorch)
  73. - [Adjust Build Options (Optional)](#adjust-build-options-optional)
  74. - [Docker Image](#docker-image)
  75. - [Using pre-built images](#using-pre-built-images)
  76. - [Building the image yourself](#building-the-image-yourself)
  77. - [Building the Documentation](#building-the-documentation)
  78. - [Building a PDF](#building-a-pdf)
  79. - [Previous Versions](#previous-versions)
  80. - [Getting Started](#getting-started)
  81. - [Resources](#resources)
  82. - [Communication](#communication)
  83. - [Releases and Contributing](#releases-and-contributing)
  84. - [The Team](#the-team)
  85. - [License](#license)
  86. <!-- tocstop -->
  87. ## More About PyTorch
  88. [Learn the basics of PyTorch](https://pytorch.org/tutorials/beginner/basics/intro.html)
  89. At a granular level, PyTorch is a library that consists of the following components:
  90. | Component | Description |
  91. | ---- | --- |
  92. | [**torch**](https://pytorch.org/docs/stable/torch.html) | A Tensor library like NumPy, with strong GPU support |
  93. | [**torch.autograd**](https://pytorch.org/docs/stable/autograd.html) | A tape-based automatic differentiation library that supports all differentiable Tensor operations in torch |
  94. | [**torch.jit**](https://pytorch.org/docs/stable/jit.html) | A compilation stack (TorchScript) to create serializable and optimizable models from PyTorch code |
  95. | [**torch.nn**](https://pytorch.org/docs/stable/nn.html) | A neural networks library deeply integrated with autograd designed for maximum flexibility |
  96. | [**torch.multiprocessing**](https://pytorch.org/docs/stable/multiprocessing.html) | Python multiprocessing, but with magical memory sharing of torch Tensors across processes. Useful for data loading and Hogwild training |
  97. | [**torch.utils**](https://pytorch.org/docs/stable/data.html) | DataLoader and other utility functions for convenience |
  98. Usually, PyTorch is used either as:
  99. - A replacement for NumPy to use the power of GPUs.
  100. - A deep learning research platform that provides maximum flexibility and speed.
  101. Elaborating Further:
  102. ### A GPU-Ready Tensor Library
  103. If you use NumPy, then you have used Tensors (a.k.a. ndarray).
  104. ![Tensor illustration](https://github.com/pytorch/pytorch/raw/main/docs/source/_static/img/tensor_illustration.png)
  105. PyTorch provides Tensors that can live either on the CPU or the GPU and accelerates the
  106. computation by a huge amount.
  107. We provide a wide variety of tensor routines to accelerate and fit your scientific computation needs
  108. such as slicing, indexing, mathematical operations, linear algebra, reductions.
  109. And they are fast!
  110. ### Dynamic Neural Networks: Tape-Based Autograd
  111. PyTorch has a unique way of building neural networks: using and replaying a tape recorder.
  112. Most frameworks such as TensorFlow, Theano, Caffe, and CNTK have a static view of the world.
  113. One has to build a neural network and reuse the same structure again and again.
  114. Changing the way the network behaves means that one has to start from scratch.
  115. With PyTorch, we use a technique called reverse-mode auto-differentiation, which allows you to
  116. change the way your network behaves arbitrarily with zero lag or overhead. Our inspiration comes
  117. from several research papers on this topic, as well as current and past work such as
  118. [torch-autograd](https://github.com/twitter/torch-autograd),
  119. [autograd](https://github.com/HIPS/autograd),
  120. [Chainer](https://chainer.org), etc.
  121. While this technique is not unique to PyTorch, it's one of the fastest implementations of it to date.
  122. You get the best of speed and flexibility for your crazy research.
  123. ![Dynamic graph](https://github.com/pytorch/pytorch/raw/main/docs/source/_static/img/dynamic_graph.gif)
  124. ### Python First
  125. PyTorch is not a Python binding into a monolithic C++ framework.
  126. It is built to be deeply integrated into Python.
  127. You can use it naturally like you would use [NumPy](https://www.numpy.org/) / [SciPy](https://www.scipy.org/) / [scikit-learn](https://scikit-learn.org) etc.
  128. You can write your new neural network layers in Python itself, using your favorite libraries
  129. and use packages such as [Cython](https://cython.org/) and [Numba](http://numba.pydata.org/).
  130. Our goal is to not reinvent the wheel where appropriate.
  131. ### Imperative Experiences
  132. PyTorch is designed to be intuitive, linear in thought, and easy to use.
  133. When you execute a line of code, it gets executed. There isn't an asynchronous view of the world.
  134. When you drop into a debugger or receive error messages and stack traces, understanding them is straightforward.
  135. The stack trace points to exactly where your code was defined.
  136. We hope you never spend hours debugging your code because of bad stack traces or asynchronous and opaque execution engines.
  137. ### Fast and Lean
  138. PyTorch has minimal framework overhead. We integrate acceleration libraries
  139. such as [Intel MKL](https://software.intel.com/mkl) and NVIDIA ([cuDNN](https://developer.nvidia.com/cudnn), [NCCL](https://developer.nvidia.com/nccl)) to maximize speed.
  140. At the core, its CPU and GPU Tensor and neural network backends
  141. are mature and have been tested for years.
  142. Hence, PyTorch is quite fast — whether you run small or large neural networks.
  143. The memory usage in PyTorch is extremely efficient compared to Torch or some of the alternatives.
  144. We've written custom memory allocators for the GPU to make sure that
  145. your deep learning models are maximally memory efficient.
  146. This enables you to train bigger deep learning models than before.
  147. ### Extensions Without Pain
  148. Writing new neural network modules, or interfacing with PyTorch's Tensor API was designed to be straightforward
  149. and with minimal abstractions.
  150. You can write new neural network layers in Python using the torch API
  151. [or your favorite NumPy-based libraries such as SciPy](https://pytorch.org/tutorials/advanced/numpy_extensions_tutorial.html).
  152. If you want to write your layers in C/C++, we provide a convenient extension API that is efficient and with minimal boilerplate.
  153. No wrapper code needs to be written. You can see [a tutorial here](https://pytorch.org/tutorials/advanced/cpp_extension.html) and [an example here](https://github.com/pytorch/extension-cpp).
  154. ## Installation
  155. ### Binaries
  156. Commands to install binaries via Conda or pip wheels are on our website: [https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/)
  157. #### NVIDIA Jetson Platforms
  158. Python wheels for NVIDIA's Jetson Nano, Jetson TX1/TX2, Jetson Xavier NX/AGX, and Jetson AGX Orin are provided [here](https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-10-now-available/72048) and the L4T container is published [here](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-pytorch)
  159. They require JetPack 4.2 and above, and [@dusty-nv](https://github.com/dusty-nv) and [@ptrblck](https://github.com/ptrblck) are maintaining them.
  160. ### From Source
  161. #### Prerequisites
  162. If you are installing from source, you will need:
  163. - Python 3.10 or later
  164. - A compiler that fully supports C++17, such as clang or gcc (gcc 9.4.0 or newer is required, on Linux)
  165. - Visual Studio or Visual Studio Build Tool (Windows only)
  166. \* PyTorch CI uses Visual C++ BuildTools, which come with Visual Studio Enterprise,
  167. Professional, or Community Editions. You can also install the build tools from
  168. https://visualstudio.microsoft.com/visual-cpp-build-tools/. The build tools *do not*
  169. come with Visual Studio Code by default.
  170. An example of environment setup is shown below:
  171. * Linux:
  172. ```bash
  173. $ source <CONDA_INSTALL_DIR>/bin/activate
  174. $ conda create -y -n <CONDA_NAME>
  175. $ conda activate <CONDA_NAME>
  176. ```
  177. * Windows:
  178. ```bash
  179. $ source <CONDA_INSTALL_DIR>\Scripts\activate.bat
  180. $ conda create -y -n <CONDA_NAME>
  181. $ conda activate <CONDA_NAME>
  182. $ call "C:\Program Files\Microsoft Visual Studio\<VERSION>\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
  183. ```
  184. A conda environment is not required. You can also do a PyTorch build in a
  185. standard virtual environment, e.g., created with tools like `uv`, provided
  186. your system has installed all the necessary dependencies unavailable as pip
  187. packages (e.g., CUDA, MKL.)
  188. ##### NVIDIA CUDA Support
  189. If you want to compile with CUDA support, [select a supported version of CUDA from our support matrix](https://pytorch.org/get-started/locally/), then install the following:
  190. - [NVIDIA CUDA](https://developer.nvidia.com/cuda-downloads)
  191. - [NVIDIA cuDNN](https://developer.nvidia.com/cudnn) v8.5 or above
  192. - [Compiler](https://gist.github.com/ax3l/9489132) compatible with CUDA
  193. Note: You could refer to the [cuDNN Support Matrix](https://docs.nvidia.com/deeplearning/cudnn/backend/latest/reference/support-matrix.html) for cuDNN versions with the various supported CUDA, CUDA driver, and NVIDIA hardware.
  194. If you want to disable CUDA support, export the environment variable `USE_CUDA=0`.
  195. Other potentially useful environment variables may be found in `setup.py`. If
  196. CUDA is installed in a non-standard location, set PATH so that the nvcc you
  197. want to use can be found (e.g., `export PATH=/usr/local/cuda-12.8/bin:$PATH`).
  198. If you are building for NVIDIA's Jetson platforms (Jetson Nano, TX1, TX2, AGX Xavier), Instructions to install PyTorch for Jetson Nano are [available here](https://devtalk.nvidia.com/default/topic/1049071/jetson-nano/pytorch-for-jetson-nano/)
  199. ##### AMD ROCm Support
  200. If you want to compile with ROCm support, install
  201. - [AMD ROCm](https://rocm.docs.amd.com/en/latest/deploy/linux/quick_start.html) 4.0 and above installation
  202. - ROCm is currently supported only for Linux systems.
  203. By default the build system expects ROCm to be installed in `/opt/rocm`. If ROCm is installed in a different directory, the `ROCM_PATH` environment variable must be set to the ROCm installation directory. The build system automatically detects the AMD GPU architecture. Optionally, the AMD GPU architecture can be explicitly set with the `PYTORCH_ROCM_ARCH` environment variable [AMD GPU architecture](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html#supported-gpus)
  204. If you want to disable ROCm support, export the environment variable `USE_ROCM=0`.
  205. Other potentially useful environment variables may be found in `setup.py`.
  206. ##### Intel GPU Support
  207. If you want to compile with Intel GPU support, follow these
  208. - [PyTorch Prerequisites for Intel GPUs](https://www.intel.com/content/www/us/en/developer/articles/tool/pytorch-prerequisites-for-intel-gpu.html) instructions.
  209. - Intel GPU is supported for Linux and Windows.
  210. If you want to disable Intel GPU support, export the environment variable `USE_XPU=0`.
  211. Other potentially useful environment variables may be found in `setup.py`.
  212. #### Get the PyTorch Source
  213. ```bash
  214. git clone https://github.com/pytorch/pytorch
  215. cd pytorch
  216. # if you are updating an existing checkout
  217. git submodule sync
  218. git submodule update --init --recursive
  219. ```
  220. #### Install Dependencies
  221. **Common**
  222. ```bash
  223. # Run this command from the PyTorch directory after cloning the source code using the “Get the PyTorch Source“ section above
  224. pip install --group dev
  225. ```
  226. **On Linux**
  227. ```bash
  228. pip install mkl-static mkl-include
  229. # CUDA only: Add LAPACK support for the GPU if needed
  230. # magma installation: run with active conda environment. specify CUDA version to install
  231. .ci/docker/common/install_magma_conda.sh 12.4
  232. # (optional) If using torch.compile with inductor/triton, install the matching version of triton
  233. # Run from the pytorch directory after cloning
  234. # For Intel GPU support, please explicitly `export USE_XPU=1` before running command.
  235. make triton
  236. ```
  237. **On MacOS**
  238. ```bash
  239. # Add this package on intel x86 processor machines only
  240. pip install mkl-static mkl-include
  241. # Add these packages if torch.distributed is needed
  242. conda install pkg-config libuv
  243. ```
  244. **On Windows**
  245. ```bash
  246. pip install mkl-static mkl-include
  247. # Add these packages if torch.distributed is needed.
  248. # Distributed package support on Windows is a prototype feature and is subject to changes.
  249. conda install -c conda-forge libuv=1.51
  250. ```
  251. #### Install PyTorch
  252. **On Linux**
  253. If you're compiling for AMD ROCm then first run this command:
  254. ```bash
  255. # Only run this if you're compiling for ROCm
  256. python tools/amd_build/build_amd.py
  257. ```
  258. Install PyTorch
  259. ```bash
  260. # the CMake prefix for conda environment
  261. export CMAKE_PREFIX_PATH="${CONDA_PREFIX:-'$(dirname $(which conda))/../'}:${CMAKE_PREFIX_PATH}"
  262. python -m pip install --no-build-isolation -v -e .
  263. # the CMake prefix for non-conda environment, e.g. Python venv
  264. # call following after activating the venv
  265. export CMAKE_PREFIX_PATH="${VIRTUAL_ENV}:${CMAKE_PREFIX_PATH}"
  266. ```
  267. **On macOS**
  268. ```bash
  269. python -m pip install --no-build-isolation -v -e .
  270. ```
  271. **On Windows**
  272. If you want to build legacy python code, please refer to [Building on legacy code and CUDA](https://github.com/pytorch/pytorch/blob/main/CONTRIBUTING.md#building-on-legacy-code-and-cuda)
  273. **CPU-only builds**
  274. In this mode PyTorch computations will run on your CPU, not your GPU.
  275. ```cmd
  276. python -m pip install --no-build-isolation -v -e .
  277. ```
  278. Note on OpenMP: The desired OpenMP implementation is Intel OpenMP (iomp). In order to link against iomp, you'll need to manually download the library and set up the building environment by tweaking `CMAKE_INCLUDE_PATH` and `LIB`. The instruction [here](https://github.com/pytorch/pytorch/blob/main/docs/source/notes/windows.rst#building-from-source) is an example for setting up both MKL and Intel OpenMP. Without these configurations for CMake, Microsoft Visual C OpenMP runtime (vcomp) will be used.
  279. **CUDA based build**
  280. In this mode PyTorch computations will leverage your GPU via CUDA for faster number crunching
  281. [NVTX](https://docs.nvidia.com/gameworks/content/gameworkslibrary/nvtx/nvidia_tools_extension_library_nvtx.htm) is needed to build PyTorch with CUDA.
  282. NVTX is a part of CUDA distributive, where it is called "Nsight Compute". To install it onto an already installed CUDA run CUDA installation once again and check the corresponding checkbox.
  283. Make sure that CUDA with Nsight Compute is installed after Visual Studio.
  284. Currently, VS 2017 / 2019, and Ninja are supported as the generator of CMake. If `ninja.exe` is detected in `PATH`, then Ninja will be used as the default generator, otherwise, it will use VS 2017 / 2019.
  285. <br/> If Ninja is selected as the generator, the latest MSVC will get selected as the underlying toolchain.
  286. Additional libraries such as
  287. [Magma](https://developer.nvidia.com/magma), [oneDNN, a.k.a. MKLDNN or DNNL](https://github.com/oneapi-src/oneDNN), and [Sccache](https://github.com/mozilla/sccache) are often needed. Please refer to the [installation-helper](https://github.com/pytorch/pytorch/tree/main/.ci/pytorch/win-test-helpers/installation-helpers) to install them.
  288. You can refer to the [build_pytorch.bat](https://github.com/pytorch/pytorch/blob/main/.ci/pytorch/win-test-helpers/build_pytorch.bat) script for some other environment variables configurations
  289. ```cmd
  290. cmd
  291. :: Set the environment variables after you have downloaded and unzipped the mkl package,
  292. :: else CMake would throw an error as `Could NOT find OpenMP`.
  293. set CMAKE_INCLUDE_PATH={Your directory}\mkl\include
  294. set LIB={Your directory}\mkl\lib;%LIB%
  295. :: Read the content in the previous section carefully before you proceed.
  296. :: [Optional] If you want to override the underlying toolset used by Ninja and Visual Studio with CUDA, please run the following script block.
  297. :: "Visual Studio 2019 Developer Command Prompt" will be run automatically.
  298. :: Make sure you have CMake >= 3.12 before you do this when you use the Visual Studio generator.
  299. set CMAKE_GENERATOR_TOOLSET_VERSION=14.27
  300. set DISTUTILS_USE_SDK=1
  301. for /f "usebackq tokens=*" %i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version [15^,17^) -products * -latest -property installationPath`) do call "%i\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=%CMAKE_GENERATOR_TOOLSET_VERSION%
  302. :: [Optional] If you want to override the CUDA host compiler
  303. set CUDAHOSTCXX=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64\cl.exe
  304. python -m pip install --no-build-isolation -v -e .
  305. ```
  306. **Intel GPU builds**
  307. In this mode PyTorch with Intel GPU support will be built.
  308. Please make sure [the common prerequisites](#prerequisites) as well as [the prerequisites for Intel GPU](#intel-gpu-support) are properly installed and the environment variables are configured prior to starting the build. For build tool support, `Visual Studio 2022` is required.
  309. Then PyTorch can be built with the command:
  310. ```cmd
  311. :: CMD Commands:
  312. :: Set the CMAKE_PREFIX_PATH to help find corresponding packages
  313. :: %CONDA_PREFIX% only works after `conda activate custom_env`
  314. if defined CMAKE_PREFIX_PATH (
  315. set "CMAKE_PREFIX_PATH=%CONDA_PREFIX%\Library;%CMAKE_PREFIX_PATH%"
  316. ) else (
  317. set "CMAKE_PREFIX_PATH=%CONDA_PREFIX%\Library"
  318. )
  319. python -m pip install --no-build-isolation -v -e .
  320. ```
  321. ##### Adjust Build Options (Optional)
  322. You can adjust the configuration of cmake variables optionally (without building first), by doing
  323. the following. For example, adjusting the pre-detected directories for CuDNN or BLAS can be done
  324. with such a step.
  325. On Linux
  326. ```bash
  327. export CMAKE_PREFIX_PATH="${CONDA_PREFIX:-'$(dirname $(which conda))/../'}:${CMAKE_PREFIX_PATH}"
  328. CMAKE_ONLY=1 python setup.py build
  329. ccmake build # or cmake-gui build
  330. ```
  331. On macOS
  332. ```bash
  333. export CMAKE_PREFIX_PATH="${CONDA_PREFIX:-'$(dirname $(which conda))/../'}:${CMAKE_PREFIX_PATH}"
  334. MACOSX_DEPLOYMENT_TARGET=11.0 CMAKE_ONLY=1 python setup.py build
  335. ccmake build # or cmake-gui build
  336. ```
  337. ### Docker Image
  338. #### Using pre-built images
  339. You can also pull a pre-built docker image from Docker Hub and run with docker v19.03+
  340. ```bash
  341. docker run --gpus all --rm -ti --ipc=host pytorch/pytorch:latest
  342. ```
  343. Please note that PyTorch uses shared memory to share data between processes, so if torch multiprocessing is used (e.g.
  344. for multithreaded data loaders) the default shared memory segment size that container runs with is not enough, and you
  345. should increase shared memory size either with `--ipc=host` or `--shm-size` command line options to `nvidia-docker run`.
  346. #### Building the image yourself
  347. **NOTE:** Must be built with a docker version > 18.06
  348. The `Dockerfile` is supplied to build images with CUDA 11.1 support and cuDNN v8.
  349. You can pass `PYTHON_VERSION=x.y` make variable to specify which Python version is to be used by Miniconda, or leave it
  350. unset to use the default.
  351. ```bash
  352. make -f docker.Makefile
  353. # images are tagged as docker.io/${your_docker_username}/pytorch
  354. ```
  355. You can also pass the `CMAKE_VARS="..."` environment variable to specify additional CMake variables to be passed to CMake during the build.
  356. See [setup.py](./setup.py) for the list of available variables.
  357. ```bash
  358. make -f docker.Makefile
  359. ```
  360. ### Building the Documentation
  361. To build documentation in various formats, you will need [Sphinx](http://www.sphinx-doc.org)
  362. and the pytorch_sphinx_theme2.
  363. Before you build the documentation locally, ensure `torch` is
  364. installed in your environment. For small fixes, you can install the
  365. nightly version as described in [Getting Started](https://pytorch.org/get-started/locally/).
  366. For more complex fixes, such as adding a new module and docstrings for
  367. the new module, you might need to install torch [from source](#from-source).
  368. See [Docstring Guidelines](https://github.com/pytorch/pytorch/wiki/Docstring-Guidelines)
  369. for docstring conventions.
  370. ```bash
  371. cd docs/
  372. pip install -r requirements.txt
  373. make html
  374. make serve
  375. ```
  376. Run `make` to get a list of all available output formats.
  377. If you get a katex error run `npm install katex`. If it persists, try
  378. `npm install -g katex`
  379. > [!NOTE]
  380. > If you installed `nodejs` with a different package manager (e.g.,
  381. > `conda`) then `npm` will probably install a version of `katex` that is not
  382. > compatible with your version of `nodejs` and doc builds will fail.
  383. > A combination of versions that is known to work is `node@6.13.1` and
  384. > `katex@0.13.18`. To install the latter with `npm` you can run
  385. > ```npm install -g katex@0.13.18```
  386. > [!NOTE]
  387. > If you see a numpy incompatibility error, run:
  388. > ```
  389. > pip install 'numpy<2'
  390. > ```
  391. When you make changes to the dependencies run by CI, edit the
  392. `.ci/docker/requirements-docs.txt` file.
  393. #### Building a PDF
  394. To compile a PDF of all PyTorch documentation, ensure you have
  395. `texlive` and LaTeX installed. On macOS, you can install them using:
  396. ```
  397. brew install --cask mactex
  398. ```
  399. To create the PDF:
  400. 1. Run:
  401. ```
  402. make latexpdf
  403. ```
  404. This will generate the necessary files in the `build/latex` directory.
  405. 2. Navigate to this directory and execute:
  406. ```
  407. make LATEXOPTS="-interaction=nonstopmode"
  408. ```
  409. This will produce a `pytorch.pdf` with the desired content. Run this
  410. command one more time so that it generates the correct table
  411. of contents and index.
  412. > [!NOTE]
  413. > To view the Table of Contents, switch to the **Table of Contents**
  414. > view in your PDF viewer.
  415. ### Previous Versions
  416. Installation instructions and binaries for previous PyTorch versions may be found
  417. on [our website](https://pytorch.org/get-started/previous-versions).
  418. ## Getting Started
  419. Three pointers to get you started:
  420. - [Tutorials: get you started with understanding and using PyTorch](https://pytorch.org/tutorials/)
  421. - [Examples: easy to understand PyTorch code across all domains](https://github.com/pytorch/examples)
  422. - [The API Reference](https://pytorch.org/docs/)
  423. - [Glossary](https://github.com/pytorch/pytorch/blob/main/GLOSSARY.md)
  424. ## Resources
  425. * [PyTorch.org](https://pytorch.org/)
  426. * [PyTorch Tutorials](https://pytorch.org/tutorials/)
  427. * [PyTorch Examples](https://github.com/pytorch/examples)
  428. * [PyTorch Models](https://pytorch.org/hub/)
  429. * [Intro to Deep Learning with PyTorch from Udacity](https://www.udacity.com/course/deep-learning-pytorch--ud188)
  430. * [Intro to Machine Learning with PyTorch from Udacity](https://www.udacity.com/course/intro-to-machine-learning-nanodegree--nd229)
  431. * [Deep Neural Networks with PyTorch from Coursera](https://www.coursera.org/learn/deep-neural-networks-with-pytorch)
  432. * [PyTorch Twitter](https://twitter.com/PyTorch)
  433. * [PyTorch Blog](https://pytorch.org/blog/)
  434. * [PyTorch YouTube](https://www.youtube.com/channel/UCWXI5YeOsh03QvJ59PMaXFw)
  435. ## Communication
  436. * Forums: Discuss implementations, research, etc. https://discuss.pytorch.org
  437. * GitHub Issues: Bug reports, feature requests, install issues, RFCs, thoughts, etc.
  438. * Slack: The [PyTorch Slack](https://pytorch.slack.com/) hosts a primary audience of moderate to experienced PyTorch users and developers for general chat, online discussions, collaboration, etc. If you are a beginner looking for help, the primary medium is [PyTorch Forums](https://discuss.pytorch.org). If you need a slack invite, please fill this form: https://goo.gl/forms/PP1AGvNHpSaJP8to1
  439. * Newsletter: No-noise, a one-way email newsletter with important announcements about PyTorch. You can sign-up here: https://eepurl.com/cbG0rv
  440. * Facebook Page: Important announcements about PyTorch. https://www.facebook.com/pytorch
  441. * For brand guidelines, please visit our website at [pytorch.org](https://pytorch.org/)
  442. ## Releases and Contributing
  443. Typically, PyTorch has three minor releases a year. Please let us know if you encounter a bug by [filing an issue](https://github.com/pytorch/pytorch/issues).
  444. We appreciate all contributions. If you are planning to contribute back bug-fixes, please do so without any further discussion.
  445. If you plan to contribute new features, utility functions, or extensions to the core, please first open an issue and discuss the feature with us.
  446. Sending a PR without discussion might end up resulting in a rejected PR because we might be taking the core in a different direction than you might be aware of.
  447. To learn more about making a contribution to PyTorch, please see our [Contribution page](CONTRIBUTING.md). For more information about PyTorch releases, see [Release page](RELEASE.md).
  448. ## The Team
  449. PyTorch is a community-driven project with several skillful engineers and researchers contributing to it.
  450. PyTorch is currently maintained by [Soumith Chintala](http://soumith.ch), [Gregory Chanan](https://github.com/gchanan), [Dmytro Dzhulgakov](https://github.com/dzhulgakov), [Edward Yang](https://github.com/ezyang), [Alban Desmaison](https://github.com/albanD), [Piotr Bialecki](https://github.com/ptrblck) and [Nikita Shulga](https://github.com/malfet) with major contributions coming from hundreds of talented individuals in various forms and means.
  451. A non-exhaustive but growing list needs to mention: [Trevor Killeen](https://github.com/killeent), [Sasank Chilamkurthy](https://github.com/chsasank), [Sergey Zagoruyko](https://github.com/szagoruyko), [Adam Lerer](https://github.com/adamlerer), [Francisco Massa](https://github.com/fmassa), [Alykhan Tejani](https://github.com/alykhantejani), [Luca Antiga](https://github.com/lantiga), [Alban Desmaison](https://github.com/albanD), [Andreas Koepf](https://github.com/andreaskoepf), [James Bradbury](https://github.com/jekbradbury), [Zeming Lin](https://github.com/ebetica), [Yuandong Tian](https://github.com/yuandong-tian), [Guillaume Lample](https://github.com/glample), [Marat Dukhan](https://github.com/Maratyszcza), [Natalia Gimelshein](https://github.com/ngimel), [Christian Sarofeen](https://github.com/csarofeen), [Martin Raison](https://github.com/martinraison), [Edward Yang](https://github.com/ezyang), [Zachary Devito](https://github.com/zdevito). <!-- codespell:ignore -->
  452. Note: This project is unrelated to [hughperkins/pytorch](https://github.com/hughperkins/pytorch) with the same name. Hugh is a valuable contributor to the Torch community and has helped with many things Torch and PyTorch.
  453. ## License
  454. PyTorch has a BSD-style license, as found in the [LICENSE](LICENSE) file.