PyTorch 文档¶
PyTorch 是一个使用 GPU 和 CPU 进行深度学习的优化张量库。
本文件中描述的功能按发布状态分类:
稳定: 这些功能将长期维护,通常不会有重大的性能限制或文档中的空白。 我们还预计将保持向后兼容性(尽管可能会发生重大更改,并且会在发布前一个版本时给出通知)。
Beta: 这些功能被标记为Beta,因为API可能会根据用户反馈进行更改,因为性能需要改进,或者因为运营商的覆盖范围尚未完全。对于Beta功能,我们承诺将其推进到稳定分类。然而,我们并不承诺向后兼容。
原型: 这些功能通常不作为二进制分发版(如PyPI或Conda)的一部分提供,除非有时在运行时标志后面,并且处于早期阶段以供反馈和测试。
开发者笔记
语言绑定
Python API
- torch
 - torch.nn
 - torch.nn.functional
 - torch.Tensor
 - 张量属性
 - 张量视图
 - torch.amp
 - torch.autograd
 - torch.library
 - torch.cpu
 - torch.cuda
- StreamContext
 - torch.cuda.can_device_access_peer
 - torch.cuda.当前_blas_句柄
 - torch.cuda.current_device
 - torch.cuda.当前流
 - torch.cuda.默认流
 - 设备
 - torch.cuda.device_count
 - device_of
 - torch.cuda.get_arch_list
 - torch.cuda.get_device_capability
 - torch.cuda.get_device_name
 - torch.cuda.get_device_properties
 - torch.cuda.get_gencode_flags
 - torch.cuda.get_sync_debug_mode
 - torch.cuda.init
 - torch.cuda.ipc_collect
 - torch.cuda.is_available
 - torch.cuda.is_initialized
 - torch.cuda.memory_usage
 - torch.cuda.set_device
 - torch.cuda.设置流
 - torch.cuda.set_同步调试模式
 - torch.cuda.stream
 - torch.cuda.synchronize
 - torch.cuda.utilization
 - torch.cuda.温度
 - torch.cuda.功率消耗
 - torch.cuda.clock_率
 - torch.cuda.内存不足错误
 - 随机数生成器
 - 通信集体
 - 流和事件
 - 图表 (beta)
 - 内存管理
 - NVIDIA 工具扩展 (NVTX)
 - Jiterator (测试版)
 - 流清理器(原型)
 
 - 理解CUDA内存使用
 - 生成快照
 - 使用可视化工具
 - 快照API参考
 - torch.mps
 - torch.xpu
- StreamContext
 - torch.xpu.current_device
 - torch.xpu.current_stream
 - 设备
 - torch.xpu.device_count
 - device_of
 - torch.xpu.empty_cache
 - torch.xpu.获取设备能力
 - torch.xpu.获取设备名称
 - torch.xpu.get_device_properties
 - torch.xpu.init
 - torch.xpu.is_available
 - torch.xpu.is_initialized
 - torch.xpu.set_device
 - torch.xpu.set_stream
 - torch.xpu.stream
 - torch.xpu.synchronize
 - 随机数生成器
 - 流和事件
 
 - Meta 设备
 - torch.backends
 - torch.export
 - torch.distributed
 - torch.distributed.algorithms.join
 - torch.distributed.elastic
 - torch.distributed.fsdp
 - torch.distributed.optim
 - torch.distributed.tensor.parallel
 - torch.distributed.checkpoint
save()async_save()save_state_dict()load()load_state_dict()StatefulStorageReaderStorageWriterLoadPlannerLoadPlan读取项SavePlannerSavePlanWriteItem文件系统读取器文件系统写入器FsspecReaderFsspecWriter默认保存计划器默认加载计划器get_state_dict()get_model_state_dict()get_optimizer_state_dict()set_state_dict()set_model_state_dict()set_optimizer_state_dict()StateDictOptionsdcp_to_torch_save()torch_save_to_dcp()BroadcastingTorchSaveReaderDynamicMetaLoadPlanner
 - torch.distributions
 - torch.compiler
 - torch.fft
 - torch.func
 - torch.futures
 - torch.fx
 - torch.fx.experimental
 - torch.hub
 - torch.jit
 - torch.linalg
 - torch.monitor
 - torch.信号
 - torch.special
 - torch.overrides
 - torch.package
 - torch.profiler
 - torch.nn.init
 - torch.nn.attention
 - torch.onnx
 - torch.optim
 - 复数
 - DDP 通信钩子
 - 流水线并行
 - 量化
 - 分布式 RPC 框架
 - torch.random
 - torch.masked
 - torch.nested
 - torch.sparse
 - torch.Storage
 - torch.测试
 - torch.utils
 - torch.utils.benchmark
 - torch.utils.bottleneck
 - torch.utils.checkpoint
 - torch.utils.cpp_extension
 - torch.utils.data
 - torch.utils.deterministic
 - torch.utils.jit
 - torch.utils.dlpack
 - torch.utils.mobile_optimizer
 - torch.utils.model_zoo
 - torch.utils.tensorboard
 - 类型信息
 - 命名张量
 - 命名张量操作符覆盖
 - torch.__config__
 - torch.__future__
 - torch._logging
 - Torch 环境变量