PyTorch is a Python package for GPU-backed tensor math and tape-based automatic differentiation. It includes flexible neural network building blocks for research and production workflows.
Overview
PyTorch is a Python package for numerical computing and deep learning. It offers tensor operations comparable to NumPy, with tensors that can run on CPU or GPU, and builds neural networks on a tape-based autograd system for automatic differentiation.
Core pieces include the torch tensor library, torch.autograd for differentiable operations, torch.nn for network modules integrated with autograd, torch.multiprocessing for shared tensor memory across processes, and torch.utils with DataLoader and related helpers. You can combine it with NumPy, SciPy, Cython, and custom C or C++ extensions.
Networks are defined imperatively: execution follows your code line by line, and reverse-mode autograd lets you change network behavior without rebuilding a fixed graph. Accelerated backends draw on libraries such as Intel MKL and NVIDIA cuDNN and NCCL for CPU and GPU work.
Install wheels or conda packages on Linux, macOS, or Windows, or build from source with optional CUDA, ROCm, or Intel GPU support. Pre-built Docker images are available, and the ecosystem includes TorchScript, TorchServe, torch.distributed, and related community projects for vision, NLP, and graphs.
Typical uses include GPU-accelerated scientific tensor code as an alternative to NumPy-only workflows, and flexible deep learning experiments where dynamic network structure matters.
Key features
- CPU and GPU tensor operations
- Tape-based automatic differentiation
- torch.nn neural network modules
- DataLoader and training utilities
- Multiprocessing with shared tensors
- TorchScript and TorchServe paths
- Distributed training via torch.distributed
- Python and C/C++ extension APIs
Use cases
- GPU-accelerated tensor and linear algebra
- Deep learning research with dynamic graphs
- Training with multi-process data loading
- Production deployment with TorchServe
- Distributed model training