METADATA 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. Metadata-Version: 2.1
  2. Name: torch
  3. Version: 2.11.0
  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. Requires-Dist: cuda-toolkit[cublas,cudart,cufft,cufile,cupti,curand,cusolver,cusparse,nvjitlink,nvrtc,nvtx]==13.0.2; platform_system == "Linux"
  42. Requires-Dist: cuda-bindings<14,>=13.0.3; platform_system == "Linux"
  43. Requires-Dist: nvidia-cudnn-cu13==9.19.0.56; platform_system == "Linux"
  44. Requires-Dist: nvidia-cusparselt-cu13==0.8.0; platform_system == "Linux"
  45. Requires-Dist: nvidia-nccl-cu13==2.28.9; platform_system == "Linux"
  46. Requires-Dist: nvidia-nvshmem-cu13==3.4.5; platform_system == "Linux"
  47. Requires-Dist: triton==3.6.0; platform_system == "Linux"
  48. Provides-Extra: opt-einsum
  49. Requires-Dist: opt-einsum>=3.3; extra == "opt-einsum"
  50. Provides-Extra: optree
  51. Requires-Dist: optree>=0.13.0; extra == "optree"
  52. Provides-Extra: pyyaml
  53. Requires-Dist: pyyaml; extra == "pyyaml"
  54. ![PyTorch Logo](https://github.com/pytorch/pytorch/raw/main/docs/source/_static/img/pytorch-logo-dark.png)
  55. --------------------------------------------------------------------------------
  56. PyTorch is a Python package that provides two high-level features:
  57. - Tensor computation (like NumPy) with strong GPU acceleration
  58. - Deep neural networks built on a tape-based autograd system
  59. You can reuse your favorite Python packages such as NumPy, SciPy, and Cython to extend PyTorch when needed.
  60. Our trunk health (Continuous Integration signals) can be found at [hud.pytorch.org](https://hud.pytorch.org/ci/pytorch/pytorch/main).
  61. <!-- toc -->
  62. - [More About PyTorch](#more-about-pytorch)
  63. - [A GPU-Ready Tensor Library](#a-gpu-ready-tensor-library)
  64. - [Dynamic Neural Networks: Tape-Based Autograd](#dynamic-neural-networks-tape-based-autograd)
  65. - [Python First](#python-first)
  66. - [Imperative Experiences](#imperative-experiences)
  67. - [Fast and Lean](#fast-and-lean)
  68. - [Extensions Without Pain](#extensions-without-pain)
  69. - [Installation](#installation)
  70. - [Binaries](#binaries)
  71. - [NVIDIA Jetson Platforms](#nvidia-jetson-platforms)
  72. - [From Source](#from-source)
  73. - [Prerequisites](#prerequisites)
  74. - [NVIDIA CUDA Support](#nvidia-cuda-support)
  75. - [AMD ROCm Support](#amd-rocm-support)
  76. - [Intel GPU Support](#intel-gpu-support)
  77. - [Get the PyTorch Source](#get-the-pytorch-source)
  78. - [Install Dependencies](#install-dependencies)
  79. - [Install PyTorch](#install-pytorch)
  80. - [Adjust Build Options (Optional)](#adjust-build-options-optional)
  81. - [Docker Image](#docker-image)
  82. - [Using pre-built images](#using-pre-built-images)
  83. - [Building the image yourself](#building-the-image-yourself)
  84. - [Building the Documentation](#building-the-documentation)
  85. - [Building a PDF](#building-a-pdf)
  86. - [Previous Versions](#previous-versions)
  87. - [Getting Started](#getting-started)
  88. - [Resources](#resources)
  89. - [Communication](#communication)
  90. - [Releases and Contributing](#releases-and-contributing)
  91. - [The Team](#the-team)
  92. - [License](#license)
  93. <!-- tocstop -->
  94. ## More About PyTorch
  95. [Learn the basics of PyTorch](https://pytorch.org/tutorials/beginner/basics/intro.html)
  96. At a granular level, PyTorch is a library that consists of the following components:
  97. | Component | Description |
  98. | ---- | --- |
  99. | [**torch**](https://pytorch.org/docs/stable/torch.html) | A Tensor library like NumPy, with strong GPU support |
  100. | [**torch.autograd**](https://pytorch.org/docs/stable/autograd.html) | A tape-based automatic differentiation library that supports all differentiable Tensor operations in torch |
  101. | [**torch.jit**](https://pytorch.org/docs/stable/jit.html) | A compilation stack (TorchScript) to create serializable and optimizable models from PyTorch code |
  102. | [**torch.nn**](https://pytorch.org/docs/stable/nn.html) | A neural networks library deeply integrated with autograd designed for maximum flexibility |
  103. | [**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 |
  104. | [**torch.utils**](https://pytorch.org/docs/stable/data.html) | DataLoader and other utility functions for convenience |
  105. Usually, PyTorch is used either as:
  106. - A replacement for NumPy to use the power of GPUs.
  107. - A deep learning research platform that provides maximum flexibility and speed.
  108. Elaborating Further:
  109. ### A GPU-Ready Tensor Library
  110. If you use NumPy, then you have used Tensors (a.k.a. ndarray).
  111. ![Tensor illustration](https://github.com/pytorch/pytorch/raw/main/docs/source/_static/img/tensor_illustration.png)
  112. PyTorch provides Tensors that can live either on the CPU or the GPU and accelerates the
  113. computation by a huge amount.
  114. We provide a wide variety of tensor routines to accelerate and fit your scientific computation needs
  115. such as slicing, indexing, mathematical operations, linear algebra, reductions.
  116. And they are fast!
  117. ### Dynamic Neural Networks: Tape-Based Autograd
  118. PyTorch has a unique way of building neural networks: using and replaying a tape recorder.
  119. Most frameworks such as TensorFlow, Theano, Caffe, and CNTK have a static view of the world.
  120. One has to build a neural network and reuse the same structure again and again.
  121. Changing the way the network behaves means that one has to start from scratch.
  122. With PyTorch, we use a technique called reverse-mode auto-differentiation, which allows you to
  123. change the way your network behaves arbitrarily with zero lag or overhead. Our inspiration comes
  124. from several research papers on this topic, as well as current and past work such as
  125. [torch-autograd](https://github.com/twitter/torch-autograd),
  126. [autograd](https://github.com/HIPS/autograd),
  127. [Chainer](https://chainer.org), etc.
  128. While this technique is not unique to PyTorch, it's one of the fastest implementations of it to date.
  129. You get the best of speed and flexibility for your crazy research.
  130. ![Dynamic graph](https://github.com/pytorch/pytorch/raw/main/docs/source/_static/img/dynamic_graph.gif)
  131. ### Python First
  132. PyTorch is not a Python binding into a monolithic C++ framework.
  133. It is built to be deeply integrated into Python.
  134. 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.
  135. You can write your new neural network layers in Python itself, using your favorite libraries
  136. and use packages such as [Cython](https://cython.org/) and [Numba](http://numba.pydata.org/).
  137. Our goal is to not reinvent the wheel where appropriate.
  138. ### Imperative Experiences
  139. PyTorch is designed to be intuitive, linear in thought, and easy to use.
  140. When you execute a line of code, it gets executed. There isn't an asynchronous view of the world.
  141. When you drop into a debugger or receive error messages and stack traces, understanding them is straightforward.
  142. The stack trace points to exactly where your code was defined.
  143. We hope you never spend hours debugging your code because of bad stack traces or asynchronous and opaque execution engines.
  144. ### Fast and Lean
  145. PyTorch has minimal framework overhead. We integrate acceleration libraries
  146. 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.
  147. At the core, its CPU and GPU Tensor and neural network backends
  148. are mature and have been tested for years.
  149. Hence, PyTorch is quite fast — whether you run small or large neural networks.
  150. The memory usage in PyTorch is extremely efficient compared to Torch or some of the alternatives.
  151. We've written custom memory allocators for the GPU to make sure that
  152. your deep learning models are maximally memory efficient.
  153. This enables you to train bigger deep learning models than before.
  154. ### Extensions Without Pain
  155. Writing new neural network modules, or interfacing with PyTorch's Tensor API was designed to be straightforward
  156. and with minimal abstractions.
  157. You can write new neural network layers in Python using the torch API
  158. [or your favorite NumPy-based libraries such as SciPy](https://pytorch.org/tutorials/advanced/numpy_extensions_tutorial.html).
  159. If you want to write your layers in C/C++, we provide a convenient extension API that is efficient and with minimal boilerplate.
  160. 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).
  161. ## Installation
  162. ### Binaries
  163. 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/)
  164. #### NVIDIA Jetson Platforms
  165. 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)
  166. They require JetPack 4.2 and above, and [@dusty-nv](https://github.com/dusty-nv) and [@ptrblck](https://github.com/ptrblck) are maintaining them.
  167. ### From Source
  168. #### Prerequisites
  169. If you are installing from source, you will need:
  170. - Python 3.10 or later
  171. - A compiler that fully supports C++17, such as clang or gcc (gcc 9.4.0 or newer is required, on Linux)
  172. - Visual Studio or Visual Studio Build Tool (Windows only)
  173. \* PyTorch CI uses Visual C++ BuildTools, which come with Visual Studio Enterprise,
  174. Professional, or Community Editions. You can also install the build tools from
  175. https://visualstudio.microsoft.com/visual-cpp-build-tools/. The build tools *do not*
  176. come with Visual Studio Code by default.
  177. An example of environment setup is shown below:
  178. * Linux:
  179. ```bash
  180. $ source <CONDA_INSTALL_DIR>/bin/activate
  181. $ conda create -y -n <CONDA_NAME>
  182. $ conda activate <CONDA_NAME>
  183. ```
  184. * Windows:
  185. ```bash
  186. $ source <CONDA_INSTALL_DIR>\Scripts\activate.bat
  187. $ conda create -y -n <CONDA_NAME>
  188. $ conda activate <CONDA_NAME>
  189. $ call "C:\Program Files\Microsoft Visual Studio\<VERSION>\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
  190. ```
  191. A conda environment is not required. You can also do a PyTorch build in a
  192. standard virtual environment, e.g., created with tools like `uv`, provided
  193. your system has installed all the necessary dependencies unavailable as pip
  194. packages (e.g., CUDA, MKL.)
  195. ##### NVIDIA CUDA Support
  196. 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:
  197. - [NVIDIA CUDA](https://developer.nvidia.com/cuda-downloads)
  198. - [NVIDIA cuDNN](https://developer.nvidia.com/cudnn) v8.5 or above
  199. - [Compiler](https://gist.github.com/ax3l/9489132) compatible with CUDA
  200. 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.
  201. If you want to disable CUDA support, export the environment variable `USE_CUDA=0`.
  202. Other potentially useful environment variables may be found in `setup.py`. If
  203. CUDA is installed in a non-standard location, set PATH so that the nvcc you
  204. want to use can be found (e.g., `export PATH=/usr/local/cuda-12.8/bin:$PATH`).
  205. 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/)
  206. ##### AMD ROCm Support
  207. If you want to compile with ROCm support, install
  208. - [AMD ROCm](https://rocm.docs.amd.com/en/latest/deploy/linux/quick_start.html) 4.0 and above installation
  209. - ROCm is currently supported only for Linux systems.
  210. 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)
  211. If you want to disable ROCm support, export the environment variable `USE_ROCM=0`.
  212. Other potentially useful environment variables may be found in `setup.py`.
  213. ##### Intel GPU Support
  214. If you want to compile with Intel GPU support, follow these
  215. - [PyTorch Prerequisites for Intel GPUs](https://www.intel.com/content/www/us/en/developer/articles/tool/pytorch-prerequisites-for-intel-gpu.html) instructions.
  216. - Intel GPU is supported for Linux and Windows.
  217. If you want to disable Intel GPU support, export the environment variable `USE_XPU=0`.
  218. Other potentially useful environment variables may be found in `setup.py`.
  219. #### Get the PyTorch Source
  220. ```bash
  221. git clone https://github.com/pytorch/pytorch
  222. cd pytorch
  223. # if you are updating an existing checkout
  224. git submodule sync
  225. git submodule update --init --recursive
  226. ```
  227. #### Install Dependencies
  228. **Common**
  229. ```bash
  230. # Run this command from the PyTorch directory after cloning the source code using the “Get the PyTorch Source“ section above
  231. pip install --group dev
  232. ```
  233. **On Linux**
  234. ```bash
  235. pip install mkl-static mkl-include
  236. # CUDA only: Add LAPACK support for the GPU if needed
  237. # magma installation: run with active conda environment. specify CUDA version to install
  238. .ci/docker/common/install_magma_conda.sh 12.4
  239. # (optional) If using torch.compile with inductor/triton, install the matching version of triton
  240. # Run from the pytorch directory after cloning
  241. # For Intel GPU support, please explicitly `export USE_XPU=1` before running command.
  242. make triton
  243. ```
  244. **On MacOS**
  245. ```bash
  246. # Add this package on intel x86 processor machines only
  247. pip install mkl-static mkl-include
  248. # Add these packages if torch.distributed is needed
  249. conda install pkg-config libuv
  250. ```
  251. **On Windows**
  252. ```bash
  253. pip install mkl-static mkl-include
  254. # Add these packages if torch.distributed is needed.
  255. # Distributed package support on Windows is a prototype feature and is subject to changes.
  256. conda install -c conda-forge libuv=1.51
  257. ```
  258. #### Install PyTorch
  259. **On Linux**
  260. If you're compiling for AMD ROCm then first run this command:
  261. ```bash
  262. # Only run this if you're compiling for ROCm
  263. python tools/amd_build/build_amd.py
  264. ```
  265. Install PyTorch
  266. ```bash
  267. # the CMake prefix for conda environment
  268. export CMAKE_PREFIX_PATH="${CONDA_PREFIX:-'$(dirname $(which conda))/../'}:${CMAKE_PREFIX_PATH}"
  269. python -m pip install --no-build-isolation -v -e .
  270. # the CMake prefix for non-conda environment, e.g. Python venv
  271. # call following after activating the venv
  272. export CMAKE_PREFIX_PATH="${VIRTUAL_ENV}:${CMAKE_PREFIX_PATH}"
  273. ```
  274. **On macOS**
  275. ```bash
  276. python -m pip install --no-build-isolation -v -e .
  277. ```
  278. **On Windows**
  279. 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)
  280. **CPU-only builds**
  281. In this mode PyTorch computations will run on your CPU, not your GPU.
  282. ```cmd
  283. python -m pip install --no-build-isolation -v -e .
  284. ```
  285. 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.
  286. **CUDA based build**
  287. In this mode PyTorch computations will leverage your GPU via CUDA for faster number crunching
  288. [NVTX](https://docs.nvidia.com/gameworks/content/gameworkslibrary/nvtx/nvidia_tools_extension_library_nvtx.htm) is needed to build PyTorch with CUDA.
  289. 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.
  290. Make sure that CUDA with Nsight Compute is installed after Visual Studio.
  291. 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.
  292. <br/> If Ninja is selected as the generator, the latest MSVC will get selected as the underlying toolchain.
  293. Additional libraries such as
  294. [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.
  295. 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
  296. ```cmd
  297. cmd
  298. :: Set the environment variables after you have downloaded and unzipped the mkl package,
  299. :: else CMake would throw an error as `Could NOT find OpenMP`.
  300. set CMAKE_INCLUDE_PATH={Your directory}\mkl\include
  301. set LIB={Your directory}\mkl\lib;%LIB%
  302. :: Read the content in the previous section carefully before you proceed.
  303. :: [Optional] If you want to override the underlying toolset used by Ninja and Visual Studio with CUDA, please run the following script block.
  304. :: "Visual Studio 2019 Developer Command Prompt" will be run automatically.
  305. :: Make sure you have CMake >= 3.12 before you do this when you use the Visual Studio generator.
  306. set CMAKE_GENERATOR_TOOLSET_VERSION=14.27
  307. set DISTUTILS_USE_SDK=1
  308. 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%
  309. :: [Optional] If you want to override the CUDA host compiler
  310. set CUDAHOSTCXX=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64\cl.exe
  311. python -m pip install --no-build-isolation -v -e .
  312. ```
  313. **Intel GPU builds**
  314. In this mode PyTorch with Intel GPU support will be built.
  315. 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.
  316. Then PyTorch can be built with the command:
  317. ```cmd
  318. :: CMD Commands:
  319. :: Set the CMAKE_PREFIX_PATH to help find corresponding packages
  320. :: %CONDA_PREFIX% only works after `conda activate custom_env`
  321. if defined CMAKE_PREFIX_PATH (
  322. set "CMAKE_PREFIX_PATH=%CONDA_PREFIX%\Library;%CMAKE_PREFIX_PATH%"
  323. ) else (
  324. set "CMAKE_PREFIX_PATH=%CONDA_PREFIX%\Library"
  325. )
  326. python -m pip install --no-build-isolation -v -e .
  327. ```
  328. ##### Adjust Build Options (Optional)
  329. You can adjust the configuration of cmake variables optionally (without building first), by doing
  330. the following. For example, adjusting the pre-detected directories for CuDNN or BLAS can be done
  331. with such a step.
  332. On Linux
  333. ```bash
  334. export CMAKE_PREFIX_PATH="${CONDA_PREFIX:-'$(dirname $(which conda))/../'}:${CMAKE_PREFIX_PATH}"
  335. CMAKE_ONLY=1 python setup.py build
  336. ccmake build # or cmake-gui build
  337. ```
  338. On macOS
  339. ```bash
  340. export CMAKE_PREFIX_PATH="${CONDA_PREFIX:-'$(dirname $(which conda))/../'}:${CMAKE_PREFIX_PATH}"
  341. MACOSX_DEPLOYMENT_TARGET=11.0 CMAKE_ONLY=1 python setup.py build
  342. ccmake build # or cmake-gui build
  343. ```
  344. ### Docker Image
  345. #### Using pre-built images
  346. You can also pull a pre-built docker image from Docker Hub and run with docker v19.03+
  347. ```bash
  348. docker run --gpus all --rm -ti --ipc=host pytorch/pytorch:latest
  349. ```
  350. Please note that PyTorch uses shared memory to share data between processes, so if torch multiprocessing is used (e.g.
  351. for multithreaded data loaders) the default shared memory segment size that container runs with is not enough, and you
  352. should increase shared memory size either with `--ipc=host` or `--shm-size` command line options to `nvidia-docker run`.
  353. #### Building the image yourself
  354. **NOTE:** Must be built with a docker version > 18.06
  355. The `Dockerfile` is supplied to build images with CUDA 11.1 support and cuDNN v8.
  356. You can pass `PYTHON_VERSION=x.y` make variable to specify which Python version is to be used by Miniconda, or leave it
  357. unset to use the default.
  358. ```bash
  359. make -f docker.Makefile
  360. # images are tagged as docker.io/${your_docker_username}/pytorch
  361. ```
  362. You can also pass the `CMAKE_VARS="..."` environment variable to specify additional CMake variables to be passed to CMake during the build.
  363. See [setup.py](./setup.py) for the list of available variables.
  364. ```bash
  365. make -f docker.Makefile
  366. ```
  367. ### Building the Documentation
  368. To build documentation in various formats, you will need [Sphinx](http://www.sphinx-doc.org)
  369. and the pytorch_sphinx_theme2.
  370. Before you build the documentation locally, ensure `torch` is
  371. installed in your environment. For small fixes, you can install the
  372. nightly version as described in [Getting Started](https://pytorch.org/get-started/locally/).
  373. For more complex fixes, such as adding a new module and docstrings for
  374. the new module, you might need to install torch [from source](#from-source).
  375. See [Docstring Guidelines](https://github.com/pytorch/pytorch/wiki/Docstring-Guidelines)
  376. for docstring conventions.
  377. ```bash
  378. cd docs/
  379. pip install -r requirements.txt
  380. make html
  381. make serve
  382. ```
  383. Run `make` to get a list of all available output formats.
  384. If you get a katex error run `npm install katex`. If it persists, try
  385. `npm install -g katex`
  386. > [!NOTE]
  387. > If you installed `nodejs` with a different package manager (e.g.,
  388. > `conda`) then `npm` will probably install a version of `katex` that is not
  389. > compatible with your version of `nodejs` and doc builds will fail.
  390. > A combination of versions that is known to work is `node@6.13.1` and
  391. > `katex@0.13.18`. To install the latter with `npm` you can run
  392. > ```npm install -g katex@0.13.18```
  393. > [!NOTE]
  394. > If you see a numpy incompatibility error, run:
  395. > ```
  396. > pip install 'numpy<2'
  397. > ```
  398. When you make changes to the dependencies run by CI, edit the
  399. `.ci/docker/requirements-docs.txt` file.
  400. #### Building a PDF
  401. To compile a PDF of all PyTorch documentation, ensure you have
  402. `texlive` and LaTeX installed. On macOS, you can install them using:
  403. ```
  404. brew install --cask mactex
  405. ```
  406. To create the PDF:
  407. 1. Run:
  408. ```
  409. make latexpdf
  410. ```
  411. This will generate the necessary files in the `build/latex` directory.
  412. 2. Navigate to this directory and execute:
  413. ```
  414. make LATEXOPTS="-interaction=nonstopmode"
  415. ```
  416. This will produce a `pytorch.pdf` with the desired content. Run this
  417. command one more time so that it generates the correct table
  418. of contents and index.
  419. > [!NOTE]
  420. > To view the Table of Contents, switch to the **Table of Contents**
  421. > view in your PDF viewer.
  422. ### Previous Versions
  423. Installation instructions and binaries for previous PyTorch versions may be found
  424. on [our website](https://pytorch.org/get-started/previous-versions).
  425. ## Getting Started
  426. Three pointers to get you started:
  427. - [Tutorials: get you started with understanding and using PyTorch](https://pytorch.org/tutorials/)
  428. - [Examples: easy to understand PyTorch code across all domains](https://github.com/pytorch/examples)
  429. - [The API Reference](https://pytorch.org/docs/)
  430. - [Glossary](https://github.com/pytorch/pytorch/blob/main/GLOSSARY.md)
  431. ## Resources
  432. * [PyTorch.org](https://pytorch.org/)
  433. * [PyTorch Tutorials](https://pytorch.org/tutorials/)
  434. * [PyTorch Examples](https://github.com/pytorch/examples)
  435. * [PyTorch Models](https://pytorch.org/hub/)
  436. * [Intro to Deep Learning with PyTorch from Udacity](https://www.udacity.com/course/deep-learning-pytorch--ud188)
  437. * [Intro to Machine Learning with PyTorch from Udacity](https://www.udacity.com/course/intro-to-machine-learning-nanodegree--nd229)
  438. * [Deep Neural Networks with PyTorch from Coursera](https://www.coursera.org/learn/deep-neural-networks-with-pytorch)
  439. * [PyTorch Twitter](https://twitter.com/PyTorch)
  440. * [PyTorch Blog](https://pytorch.org/blog/)
  441. * [PyTorch YouTube](https://www.youtube.com/channel/UCWXI5YeOsh03QvJ59PMaXFw)
  442. ## Communication
  443. * Forums: Discuss implementations, research, etc. https://discuss.pytorch.org
  444. * GitHub Issues: Bug reports, feature requests, install issues, RFCs, thoughts, etc.
  445. * 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
  446. * Newsletter: No-noise, a one-way email newsletter with important announcements about PyTorch. You can sign-up here: https://eepurl.com/cbG0rv
  447. * Facebook Page: Important announcements about PyTorch. https://www.facebook.com/pytorch
  448. * For brand guidelines, please visit our website at [pytorch.org](https://pytorch.org/)
  449. ## Releases and Contributing
  450. 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).
  451. We appreciate all contributions. If you are planning to contribute back bug-fixes, please do so without any further discussion.
  452. 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.
  453. 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.
  454. 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).
  455. ## The Team
  456. PyTorch is a community-driven project with several skillful engineers and researchers contributing to it.
  457. 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.
  458. 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 -->
  459. 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.
  460. ## License
  461. PyTorch has a BSD-style license, as found in the [LICENSE](LICENSE) file.