PyTorch torch.get_num_threads 函数

约 217 字 更新于 2026-11-18 5iyo.com

PyTorch torch.get_num_threads 函数


torch.get_num_threads 是 PyTorch 中用于获取内部并行计算线程数的函数。

函数定义

torch.get_num_threads()

使用示例

实例

import torch

# 获取当前线程数
num_threads = torch.get_num_threads()
print("当前线程数:", num_threads)