提交 a6c6face 编写于 作者: 绝不原创的飞龙's avatar 绝不原创的飞龙

2024-02-05 17:52:04

上级 df519720
- en: TorchAudio 2.2 Doc
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: TorchAudio 2.2 文档
- en: 来源:[https://pytorch.org/audio/stable/index.html](https://pytorch.org/audio/stable/index.html)
id: totrans-1
prefs: []
type: TYPE_NORMAL
zh: 'Source: [https://pytorch.org/audio/stable/index.html](https://pytorch.org/audio/stable/index.html)'
- en: Torchaudio Documentation
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: Torchaudio 文档
此差异已折叠。
- en: Supported Features
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 支持的功能
- en: 原文:[https://pytorch.org/audio/stable/supported_features.html](https://pytorch.org/audio/stable/supported_features.html)
id: totrans-1
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/audio/stable/supported_features.html](https://pytorch.org/audio/stable/supported_features.html)
- en: 'Each TorchAudio API supports a subset of PyTorch features, such as devices
and data types. Supported features are indicated in API references like the following:'
id: totrans-2
prefs: []
type: TYPE_NORMAL
zh: 每个 TorchAudio API 支持一部分 PyTorch 功能,比如设备和数据类型。支持的功能在 API 参考中标明,如下所示:
- en: '[![This feature supports the following devices: CPU, CUDA](../Images/436dcea77111f2b243d161ad46fb68d6.png)](supported_features.html#devices)
[![This API supports the following properties: Autograd, TorchScript](../Images/7f8d40aa9fa8230970316fdd270003ed.png)](supported_features.html#properties)'
id: totrans-3
prefs: []
type: TYPE_NORMAL
zh: '[![此功能支持以下设备:CPU,CUDA](../Images/436dcea77111f2b243d161ad46fb68d6.png)](supported_features.html#devices)
[![此 API 支持以下属性:Autograd,TorchScript](../Images/7f8d40aa9fa8230970316fdd270003ed.png)](supported_features.html#properties)'
- en: These icons mean that they are verified through automated testing.
id: totrans-4
prefs: []
type: TYPE_NORMAL
zh: 这些图标表示它们已通过自动化测试验证。
- en: Note
id: totrans-5
prefs: []
type: TYPE_NORMAL
zh: 注意
- en: Missing feature icons mean that they are not tested, and this can mean different
things, depending on the API.
id: totrans-6
prefs: []
type: TYPE_NORMAL
zh: 缺失的功能图标表示它们未经测试,这可能意味着不同的事情,具体取决于 API。
- en: The API is compatible with the feature but not tested.
id: totrans-7
prefs:
- PREF_OL
type: TYPE_NORMAL
zh: API 与该功能兼容,但未经测试。
- en: The API is not compatible with the feature.
id: totrans-8
prefs:
- PREF_OL
type: TYPE_NORMAL
zh: API 与该功能不兼容。
- en: In case of 2, the API might explicitly raise an error, but that is not guaranteed.
For example, APIs without an Autograd badge might throw an error during backpropagation,
or silently return a wrong gradient.
id: totrans-9
prefs: []
type: TYPE_NORMAL
zh: 在第二种情况下,API 可能会明确引发错误,但这并不保证。例如,没有 Autograd 标志的 API 可能在反向传播过程中抛出错误,或者悄悄返回错误的梯度。
- en: If you use an API that hasn’t been labeled as supporting a feature, you might
want to first verify that the feature works fine.
id: totrans-10
prefs: []
type: TYPE_NORMAL
zh: 如果您使用的 API 没有被标记为支持某个功能,您可能需要先验证该功能是否正常工作。
- en: Devices[](#devices "Permalink to this heading")
id: totrans-11
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 设备[](#设备 "此标题的永久链接")
- en: CPU[](#cpu "Permalink to this heading")
id: totrans-12
prefs:
- PREF_H3
type: TYPE_NORMAL
zh: CPU[](#cpu "此标题的永久链接")
- en: '[![This feature supports the following devices: CPU](../Images/d8168b4ee98570889e4c86c2a6aeca75.png)](supported_features.html#devices)'
id: totrans-13
prefs: []
type: TYPE_NORMAL
zh: '[![此功能支持以下设备:CPU](../Images/d8168b4ee98570889e4c86c2a6aeca75.png)](supported_features.html#devices)'
- en: TorchAudio APIs that support CPU can perform their computation on CPU tensors.
id: totrans-14
prefs: []
type: TYPE_NORMAL
zh: 支持 CPU 的 TorchAudio API 可以在 CPU 张量上执行计算。
- en: CUDA[](#cuda "Permalink to this heading")
id: totrans-15
prefs:
- PREF_H3
type: TYPE_NORMAL
zh: CUDA[](#cuda "此标题的永久链接")
- en: '[![This feature supports the following devices: CUDA](../Images/715a101451863e082b0b61bdeaec1135.png)](supported_features.html#devices)'
id: totrans-16
prefs: []
type: TYPE_NORMAL
zh: '[![此功能支持以下设备:CUDA](../Images/715a101451863e082b0b61bdeaec1135.png)](supported_features.html#devices)'
- en: TorchAudio APIs that support CUDA can perform their computation on CUDA devices.
id: totrans-17
prefs: []
type: TYPE_NORMAL
zh: 支持 CUDA 的 TorchAudio API 可以在 CUDA 设备上执行计算。
- en: In case of functions, move the tensor arguments to CUDA device before passing
them to a function.
id: totrans-18
prefs: []
type: TYPE_NORMAL
zh: 在函数的情况下,在将张量参数传递给函数之前,将它们移动到 CUDA 设备上。
- en: 'For example:'
id: totrans-19
prefs: []
type: TYPE_NORMAL
zh: 例如:
- en: '[PRE0]'
id: totrans-20
prefs: []
type: TYPE_PRE
zh: '[PRE0]'
- en: Classes with CUDA support are implemented with `torch.nn.Module()`. It is also
necessary to move the instance to CUDA device, before passing CUDA tensors.
id: totrans-21
prefs: []
type: TYPE_NORMAL
zh: 具有 CUDA 支持的类使用 `torch.nn.Module()` 实现。在传递 CUDA 张量之前,将实例移动到 CUDA 设备是必要的。
- en: 'For example:'
id: totrans-22
prefs: []
type: TYPE_NORMAL
zh: 例如:
- en: '[PRE1]'
id: totrans-23
prefs: []
type: TYPE_PRE
zh: '[PRE1]'
- en: Properties[](#properties "Permalink to this heading")
id: totrans-24
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 属性[](#属性 "此标题的永久链接")
- en: Autograd[](#autograd "Permalink to this heading")
id: totrans-25
prefs:
- PREF_H3
type: TYPE_NORMAL
zh: 自动求导[](#autograd "此标题的永久链接")
- en: '[![This API supports the following properties: Autograd](../Images/6d4055c124921ae7bf28212985a77b02.png)](supported_features.html#properties)'
id: totrans-26
prefs: []
type: TYPE_NORMAL
zh: '[![此 API 支持以下属性:Autograd](../Images/6d4055c124921ae7bf28212985a77b02.png)](supported_features.html#properties)'
- en: TorchAudio APIs with autograd support can correctly backpropagate gradients.
id: totrans-27
prefs: []
type: TYPE_NORMAL
zh: 支持自动求导的 TorchAudio API 可以正确地反向传播梯度。
- en: For the basics of autograd, please refer to this [tutorial](https://pytorch.org/tutorials/beginner/blitz/autograd_tutorial.html).
id: totrans-28
prefs: []
type: TYPE_NORMAL
zh: 有关自动求导的基础知识,请参考这个[教程](https://pytorch.org/tutorials/beginner/blitz/autograd_tutorial.html)。
- en: Note
id: totrans-29
prefs: []
type: TYPE_NORMAL
zh: 注意
- en: APIs without this mark may or may not raise an error during backpropagation.
The absence of an error raised during backpropagation does not necessarily mean
the gradient is correct.
id: totrans-30
prefs: []
type: TYPE_NORMAL
zh: 没有此标记的 API 在反向传播过程中可能会引发错误,也可能不会。在反向传播过程中没有引发错误并不一定意味着梯度是正确的。
- en: TorchScript[](#torchscript "Permalink to this heading")
id: totrans-31
prefs:
- PREF_H3
type: TYPE_NORMAL
zh: TorchScript[](#torchscript "此标题的永久链接")
- en: '[![This API supports the following properties: TorchScript](../Images/f8384797bafe9e7b6155ead9932a3063.png)](supported_features.html#properties)'
id: totrans-32
prefs: []
type: TYPE_NORMAL
zh: '[![此 API 支持以下属性:TorchScript](../Images/f8384797bafe9e7b6155ead9932a3063.png)](supported_features.html#properties)'
- en: TorchAudio APIs with TorchScript support can be serialized and executed in non-Python
environments.
id: totrans-33
prefs: []
type: TYPE_NORMAL
zh: 具有 TorchScript 支持的 TorchAudio API 可以在非 Python 环境中序列化和执行。
- en: For details on TorchScript, please refer to the [documentation](https://pytorch.org/docs/stable/jit.html).
id: totrans-34
prefs: []
type: TYPE_NORMAL
zh: 有关 TorchScript 的详细信息,请参考[文档](https://pytorch.org/docs/stable/jit.html)。
- en: Feature Classifications
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 功能分类
- en: 原文:[https://pytorch.org/audio/stable/feature_classifications.html](https://pytorch.org/audio/stable/feature_classifications.html)
id: totrans-1
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/audio/stable/feature_classifications.html](https://pytorch.org/audio/stable/feature_classifications.html)
- en: 'Features described in this documentation are classified by release status:'
id: totrans-2
prefs: []
type: TYPE_NORMAL
zh: 本文档中描述的功能按发布状态分类:
- en: '*Stable:* These features will be maintained long-term and there should generally
be no major performance limitations or gaps in documentation. We also expect to
maintain backwards compatibility (although breaking changes can happen and notice
will be given one release ahead of time).'
id: totrans-3
prefs: []
type: TYPE_NORMAL
zh: 稳定:这些功能将长期保持,并且通常不会有主要性能限制或文档中的差距。我们也希望保持向后兼容性(尽管可能会发生破坏性更改,并且会提前一个版本发布通知)。
- en: '*Beta:* Features are tagged as Beta because the API may change based on user
feedback, because the performance needs to improve, or because coverage across
operators is not yet complete. For Beta features, we are committing to seeing
the feature through to the Stable classification. We are not, however, committing
to backwards compatibility.'
id: totrans-4
prefs: []
type: TYPE_NORMAL
zh: Beta:功能被标记为Beta,因为API可能会根据用户反馈而更改,因为性能需要改进,或者因为跨运算符的覆盖范围尚未完全。对于Beta功能,我们承诺将该功能推进到稳定分类。然而,我们不承诺向后兼容。
- en: '*Prototype:* These features are typically not available as part of binary distributions
like PyPI or Conda, except sometimes behind run-time flags, and are at an early
stage for feedback and testing.'
id: totrans-5
prefs: []
type: TYPE_NORMAL
zh: 原型:这些功能通常不作为PyPI或Conda等二进制发行版的一部分提供,除非有时在运行时标志后面,并且处于反馈和测试的早期阶段。
- en: TorchAudio Logo
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: TorchAudio 标志
- en: 原文:[https://pytorch.org/audio/stable/logo.html](https://pytorch.org/audio/stable/logo.html)
id: totrans-1
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/audio/stable/logo.html](https://pytorch.org/audio/stable/logo.html)
- en: If you make your project using TorchAudio and you want to mention TorchAudio,
you can use TorchAudio logo. There are couple of variations. You can download
them from [here](https://download.pytorch.org/torchaudio/logo/v1.zip).
id: totrans-2
prefs: []
type: TYPE_NORMAL
zh: 如果您使用 TorchAudio 制作项目并想提及 TorchAudio,您可以使用 TorchAudio 标志。有几种变体。您可以从[这里](https://download.pytorch.org/torchaudio/logo/v1.zip)下载它们。
- en: Please follow [the guideline](https://download.pytorch.org/torchaudio/logo/v1/guidelines.pdf)
for the proper usage.
id: totrans-3
prefs: []
type: TYPE_NORMAL
zh: 请遵循[指南](https://download.pytorch.org/torchaudio/logo/v1/guidelines.pdf)以正确使用。
- en: Warning
id: totrans-4
prefs: []
type: TYPE_NORMAL
zh: 警告
- en: Please do not alter the logo. The guideline lists examples of inproper usages
as well, so please check them out before using the logos.
id: totrans-5
prefs: []
type: TYPE_NORMAL
zh: 请不要修改标志。指南列出了不当使用的示例,请在使用标志之前查看它们。
- en: Icon[](#icon "Permalink to this heading")
id: totrans-6
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 图标[](#icon "跳转到此标题的永久链接")
- en: '[![https://download.pytorch.org/torchaudio/logo/v1/icon.png](../Images/0f8a20b254c0a0a24667c35a283fdeee.png)](https://download.pytorch.org/torchaudio/logo/v1/icon.png)'
id: totrans-7
prefs: []
type: TYPE_NORMAL
zh: '[![https://download.pytorch.org/torchaudio/logo/v1/icon.png](../Images/0f8a20b254c0a0a24667c35a283fdeee.png)](https://download.pytorch.org/torchaudio/logo/v1/icon.png)'
- en: Horizontal[](#horizontal "Permalink to this heading")
id: totrans-8
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 水平[](#horizontal "跳转到此标题的永久链接")
- en: '[![https://download.pytorch.org/torchaudio/logo/v1/logo_horizontal_fullcolor.png](../Images/559e38269daa61bf14e53b879fe07651.png)](https://download.pytorch.org/torchaudio/logo/v1/logo_horizontal_fullcolor.png)[![https://download.pytorch.org/torchaudio/logo/v1/logo_horizontal_black.png](../Images/2f32e7bce3f2fcddac736d84499c999e.png)](https://download.pytorch.org/torchaudio/logo/v1/logo_horizontal_black.png)![](../Images/6c04bd3c064bb5a44ec0a134cbed6942.png)'
id: totrans-9
prefs: []
type: TYPE_NORMAL
zh: '[![https://download.pytorch.org/torchaudio/logo/v1/logo_horizontal_fullcolor.png](../Images/559e38269daa61bf14e53b879fe07651.png)](https://download.pytorch.org/torchaudio/logo/v1/logo_horizontal_fullcolor.png)[![https://download.pytorch.org/torchaudio/logo/v1/logo_horizontal_black.png](../Images/2f32e7bce3f2fcddac736d84499c999e.png)](https://download.pytorch.org/torchaudio/logo/v1/logo_horizontal_black.png)![](../Images/6c04bd3c064bb5a44ec0a134cbed6942.png)'
- en: Vertical[](#vertical "Permalink to this heading")
id: totrans-10
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 垂直[](#vertical "跳转到此标题的永久链接")
- en: '[![https://download.pytorch.org/torchaudio/logo/v1/logo_vertical_fullcolor.png](../Images/8b836fc7376d32939bdc379f807b28ee.png)](https://download.pytorch.org/torchaudio/logo/v1/logo_vertical_fullcolor.png)[![https://download.pytorch.org/torchaudio/logo/v1/logo_vertical_black.png](../Images/c7ceea352093f00b2e5ee364e4b30d18.png)](https://download.pytorch.org/torchaudio/logo/v1/logo_vertical_black.png)![](../Images/f6a349d770bcda78ee8a8f74f4962ff8.png)'
id: totrans-11
prefs: []
type: TYPE_NORMAL
zh: '[![https://download.pytorch.org/torchaudio/logo/v1/logo_vertical_fullcolor.png](../Images/8b836fc7376d32939bdc379f807b28ee.png)](https://download.pytorch.org/torchaudio/logo/v1/logo_vertical_fullcolor.png)[![https://download.pytorch.org/torchaudio/logo/v1/logo_vertical_black.png](../Images/c7ceea352093f00b2e5ee364e4b30d18.png)](https://download.pytorch.org/torchaudio/logo/v1/logo_vertical_black.png)![](../Images/f6a349d770bcda78ee8a8f74f4962ff8.png)'
此差异已折叠。
- en: Installation
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 安装
- en: Installing pre-built binaries
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 安装预构建的二进制文件
- en: 原文:[https://pytorch.org/audio/stable/installation.html](https://pytorch.org/audio/stable/installation.html)
id: totrans-1
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/audio/stable/installation.html](https://pytorch.org/audio/stable/installation.html)
- en: '`torchaudio` has binary distributions for PyPI (`pip`) and Anaconda (`conda`).'
id: totrans-2
prefs: []
type: TYPE_NORMAL
zh: '`torchaudio`有PyPI(`pip`)和Anaconda(`conda`)的二进制发行版。'
- en: Please refer to [https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/)
for the details.
id: totrans-3
prefs: []
type: TYPE_NORMAL
zh: 有关详细信息,请参考[https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/)。
- en: Note
id: totrans-4
prefs: []
type: TYPE_NORMAL
zh: 注意
- en: Each `torchaudio` package is compiled against specific version of `torch`. Please
refer to the following table and install the correct pair of `torch` and `torchaudio`.
id: totrans-5
prefs: []
type: TYPE_NORMAL
zh: 每个`torchaudio`包都是针对特定版本的`torch`编译的。请参考以下表格并安装正确的`torch`和`torchaudio`配对。
- en: Note
id: totrans-6
prefs: []
type: TYPE_NORMAL
zh: 注意
- en: Starting `0.10`, torchaudio has CPU-only and CUDA-enabled binary distributions,
each of which requires a corresponding PyTorch distribution.
id: totrans-7
prefs: []
type: TYPE_NORMAL
zh: 从`0.10`开始,torchaudio有仅CPU和启用CUDA的二进制发行版,每个都需要相应的PyTorch发行版。
- en: Note
id: totrans-8
prefs: []
type: TYPE_NORMAL
zh: 注意
- en: 'This software was compiled against an unmodified copies of FFmpeg, with the
specific rpath removed so as to enable the use of system libraries. The LGPL source
can be downloaded from the following locations: [n4.1.8](https://github.com/FFmpeg/FFmpeg/releases/tag/n4.4.4)
([license](https://github.com/FFmpeg/FFmpeg/blob/n4.4.4/COPYING.LGPLv2.1)), [n5.0.3](https://github.com/FFmpeg/FFmpeg/releases/tag/n5.0.3)
([license](https://github.com/FFmpeg/FFmpeg/blob/n5.0.3/COPYING.LGPLv2.1)) and
[n6.0](https://github.com/FFmpeg/FFmpeg/releases/tag/n6.0) ([license](https://github.com/FFmpeg/FFmpeg/blob/n6.0/COPYING.LGPLv2.1)).'
id: totrans-9
prefs: []
type: TYPE_NORMAL
zh: 此软件是针对未经修改的FFmpeg副本编译的,特定的rpath已被移除,以便使用系统库。LGPL源代码可以从以下位置下载:[n4.1.8](https://github.com/FFmpeg/FFmpeg/releases/tag/n4.4.4)([许可证](https://github.com/FFmpeg/FFmpeg/blob/n4.4.4/COPYING.LGPLv2.1)),[n5.0.3](https://github.com/FFmpeg/FFmpeg/releases/tag/n5.0.3)([许可证](https://github.com/FFmpeg/FFmpeg/blob/n5.0.3/COPYING.LGPLv2.1))和[n6.0](https://github.com/FFmpeg/FFmpeg/releases/tag/n6.0)([许可证](https://github.com/FFmpeg/FFmpeg/blob/n6.0/COPYING.LGPLv2.1))。
- en: Dependencies[](#dependencies "Permalink to this heading")
id: totrans-10
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 依赖项[](#dependencies "Permalink to this heading")
- en: '[PyTorch](https://pytorch.org)'
id: totrans-11
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[PyTorch](https://pytorch.org)'
- en: Please refer to the compatibility matrix bellow for supported PyTorch versions.
id: totrans-12
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 请参考下面的兼容矩阵以获取支持的PyTorch版本。
- en: '### Optional Dependencies[](#optional-dependencies "Permalink to this heading")'
id: totrans-13
prefs: []
type: TYPE_NORMAL
zh: '### 可选依赖项[](#optional-dependencies "Permalink to this heading")'
- en: '[FFmpeg](https://ffmpeg.org)'
id: totrans-14
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[FFmpeg](https://ffmpeg.org)'
- en: Required to use [`torchaudio.io`](io.html#module-torchaudio.io "torchaudio.io")
module. and `backend="ffmpeg"` in [I/O functions](./torchaudio.html#i-o).
id: totrans-15
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 需要使用[`torchaudio.io`](io.html#module-torchaudio.io "torchaudio.io")模块和在[I/O函数](./torchaudio.html#i-o)中使用`backend="ffmpeg"`。
- en: Starting version 2.1, TorchAudio official binary distributions are compatible
with FFmpeg version 6, 5 and 4\. (>=4.4, <7). At runtime, TorchAudio first looks
for FFmpeg 6, if not found, then it continues to looks for 5 and move on to 4.
id: totrans-16
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 从版本2.1开始,TorchAudio官方二进制发行版与FFmpeg版本6、5和4兼容(>=4.4,<7)。在运行时,TorchAudio首先搜索FFmpeg
6,如果未找到,则继续搜索5,然后转到4。
- en: There are multiple ways to install FFmpeg libraries. Please refer to the official
documentation for how to install FFmpeg. If you are using Anaconda Python distribution,
`conda install -c conda-forge 'ffmpeg<7'` will install compatible FFmpeg libraries.
id: totrans-17
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 有多种安装FFmpeg库的方法。请参考官方文档了解如何安装FFmpeg。如果您使用Anaconda Python发行版,`conda install -c
conda-forge 'ffmpeg<7'`将安装兼容的FFmpeg库。
- en: If you need to specify the version of FFmpeg TorchAudio searches and links,
you can specify it via the environment variable `TORIO_USE_FFMPEG_VERSION`. For
example, by setting `TORIO_USE_FFMPEG_VERSION=5`, TorchAudio will only look for
FFmpeg 5.
id: totrans-18
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 如果您需要指定TorchAudio搜索和链接的FFmpeg版本,可以通过环境变量`TORIO_USE_FFMPEG_VERSION`指定。例如,通过设置`TORIO_USE_FFMPEG_VERSION=5`,TorchAudio将只搜索FFmpeg
5。
- en: If for some reason, this search mechanism is causing an issue, you can disable
the FFmpeg integration entirely by setting the environment variable `TORIO_USE_FFMPEG=0`.
id: totrans-19
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 如果由于某种原因,此搜索机制导致问题,您可以通过设置环境变量`TORIO_USE_FFMPEG=0`完全禁用FFmpeg集成。
- en: There are multiple ways to install FFmpeg libraries. If you are using Anaconda
Python distribution, `conda install -c conda-forge 'ffmpeg<7'` will install compatible
FFmpeg libraries.
id: totrans-20
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 有多种安装FFmpeg库的方法。如果您使用Anaconda Python发行版,`conda install -c conda-forge 'ffmpeg<7'`将安装兼容的FFmpeg库。
- en: Note
id: totrans-21
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 注意
- en: When searching for FFmpeg installation, TorchAudio looks for library files which
have names with version numbers. That is, `libavutil.so.<VERSION>` for Linux,
`libavutil.<VERSION>.dylib` for macOS, and `avutil-<VERSION>.dll` for Windows.
......@@ -104,144 +151,220 @@
double check that the library files you installed follow this naming scheme, (and
then make sure that they are in one of the directories listed in library search
path.)
id: totrans-22
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 在搜索FFmpeg安装时,TorchAudio会查找具有版本号的库文件。也就是说,对于Linux是`libavutil.so.<VERSION>`,对于macOS是`libavutil.<VERSION>.dylib`,对于Windows是`avutil-<VERSION>.dll`。许多公共预构建的二进制文件遵循这种命名方案,但有些发行版具有无版本号的文件名。如果您在检测FFmpeg时遇到困难,请仔细检查您安装的库文件是否遵循这种命名方案(然后确保它们位于列出的库搜索路径之一)。
- en: '[SoX](https://sox.sourceforge.net/)'
id: totrans-23
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[SoX](https://sox.sourceforge.net/)'
- en: Required to use `backend="sox"` in [I/O functions](./torchaudio.html#i-o).
id: totrans-24
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 在[I/O函数](./torchaudio.html#i-o)中需要使用`backend="sox"`。
- en: Starting version 2.1, TorchAudio requires separately installed libsox.
id: totrans-25
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 从版本2.1开始,TorchAudio需要单独安装libsox。
- en: If dynamic linking is causing an issue, you can set the environment variable
`TORCHAUDIO_USE_SOX=0`, and TorchAudio won’t use SoX.
id: totrans-26
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 如果动态链接导致问题,您可以设置环境变量`TORCHAUDIO_USE_SOX=0`,TorchAudio将不使用SoX。
- en: Note
id: totrans-27
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 注意
- en: TorchAudio looks for a library file with unversioned name, that is `libsox.so`
for Linux, and `libsox.dylib` for macOS. Some package managers install the library
file with different name. For example, aptitude on Ubuntu installs `libsox.so.3`.
To have TorchAudio link against it, you can create a symbolic link to it with
name `libsox.so` (and put the symlink in a library search path).
id: totrans-28
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: TorchAudio在Linux上寻找具有无版本名称的库文件,即`libsox.so`,在macOS上为`libsox.dylib`。一些软件包管理器使用不同的名称安装库文件。例如,Ubuntu上的aptitude安装了`libsox.so.3`。为了让TorchAudio链接到它,您可以创建一个名为`libsox.so`的符号链接(并将符号链接放在库搜索路径中)。
- en: Note
id: totrans-29
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 注意
- en: TorchAudio is tested on libsox 14.4.2\. (And it is unlikely that other versions
would work.)
id: totrans-30
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: TorchAudio在libsox 14.4.2上进行了测试。 (其他版本可能不起作用。)
- en: '[SoundFile](https://pysoundfile.readthedocs.io/)'
id: totrans-31
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[SoundFile](https://pysoundfile.readthedocs.io/)'
- en: Required to use `backend="soundfile"` in [I/O functions](./torchaudio.html#i-o).
id: totrans-32
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 在[I/O函数](./torchaudio.html#i-o)中使用`backend="soundfile"`所需。
- en: '[sentencepiece](https://pypi.org/project/sentencepiece/)'
id: totrans-33
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[sentencepiece](https://pypi.org/project/sentencepiece/)'
- en: Required for performing automatic speech recognition with [Emformer RNN-T](pipelines.html#rnnt).
You can install it by running `pip install sentencepiece`.
id: totrans-34
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 使用[Emformer RNN-T](pipelines.html#rnnt)执行自动语音识别所需。您可以通过运行`pip install sentencepiece`来安装它。
- en: '[deep-phonemizer](https://pypi.org/project/deep-phonemizer/)'
id: totrans-35
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[deep-phonemizer](https://pypi.org/project/deep-phonemizer/)'
- en: Required for performing text-to-speech with [Tacotron2 Text-To-Speech](pipelines.html#tacotron2).
id: totrans-36
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 使用[Tacotron2 Text-To-Speech](pipelines.html#tacotron2)执行文本转语音所需。
- en: '[kaldi_io](https://pypi.org/project/kaldi-io/)'
id: totrans-37
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[kaldi_io](https://pypi.org/project/kaldi-io/)'
- en: Required to use [`torchaudio.kaldi_io`](kaldi_io.html#module-torchaudio.kaldi_io
"torchaudio.kaldi_io") module.
id: totrans-38
prefs:
- PREF_IND
type: TYPE_NORMAL
zh: 使用[`torchaudio.kaldi_io`](kaldi_io.html#module-torchaudio.kaldi_io "torchaudio.kaldi_io")模块所需。
- en: Compatibility Matrix[](#compatibility-matrix "Permalink to this heading")
id: totrans-39
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 兼容性矩阵[](#compatibility-matrix "跳转到此标题")
- en: The official binary distributions of TorchAudio contain extension modules which
are written in C++ and linked against specific versions of PyTorch.
id: totrans-40
prefs: []
type: TYPE_NORMAL
zh: TorchAudio的官方二进制发行版包含用C++编写的扩展模块,并链接到特定版本的PyTorch。
- en: TorchAudio and PyTorch from different releases cannot be used together. Please
refer to the following table for the matching versions.
id: totrans-41
prefs: []
type: TYPE_NORMAL
zh: TorchAudio和不同版本的PyTorch不能一起使用。请参考以下表格以获取匹配的版本。
- en: '| `PyTorch` | `TorchAudio` | `Python` |'
id: totrans-42
prefs: []
type: TYPE_TB
zh: '| `PyTorch` | `TorchAudio` | `Python` |'
- en: '| --- | --- | --- |'
id: totrans-43
prefs: []
type: TYPE_TB
zh: '| --- | --- | --- |'
- en: '| `2.1.0` | `2.1.0` | `>=3.8`, `<=3.11` |'
id: totrans-44
prefs: []
type: TYPE_TB
zh: '| `2.1.0` | `2.1.0` | `>=3.8`, `<=3.11` |'
- en: '| `2.0.1` | `2.0.2` | `>=3.8`, `<=3.11` |'
id: totrans-45
prefs: []
type: TYPE_TB
zh: '| `2.0.1` | `2.0.2` | `>=3.8`, `<=3.11` |'
- en: '| `2.0.0` | `2.0.1` | `>=3.8`, `<=3.11` |'
id: totrans-46
prefs: []
type: TYPE_TB
zh: '| `2.0.0` | `2.0.1` | `>=3.8`, `<=3.11` |'
- en: '| `1.13.1` | `0.13.1` | `>=3.7`, `<=3.10` |'
id: totrans-47
prefs: []
type: TYPE_TB
zh: '| `1.13.1` | `0.13.1` | `>=3.7`, `<=3.10` |'
- en: '| `1.13.0` | `0.13.0` | `>=3.7`, `<=3.10` |'
id: totrans-48
prefs: []
type: TYPE_TB
zh: '| `1.13.0` | `0.13.0` | `>=3.7`, `<=3.10` |'
- en: '| `1.12.1` | `0.12.1` | `>=3.7`, `<=3.10` |'
id: totrans-49
prefs: []
type: TYPE_TB
zh: '| `1.12.1` | `0.12.1` | `>=3.7`, `<=3.10` |'
- en: '| `1.12.0` | `0.12.0` | `>=3.7`, `<=3.10` |'
id: totrans-50
prefs: []
type: TYPE_TB
zh: '| `1.12.0` | `0.12.0` | `>=3.7`, `<=3.10` |'
- en: '| `1.11.0` | `0.11.0` | `>=3.7`, `<=3.9` |'
id: totrans-51
prefs: []
type: TYPE_TB
zh: '| `1.11.0` | `0.11.0` | `>=3.7`, `<=3.9` |'
- en: '| `1.10.0` | `0.10.0` | `>=3.6`, `<=3.9` |'
id: totrans-52
prefs: []
type: TYPE_TB
zh: '| `1.10.0` | `0.10.0` | `>=3.6`, `<=3.9` |'
- en: '| `1.9.1` | `0.9.1` | `>=3.6`, `<=3.9` |'
id: totrans-53
prefs: []
type: TYPE_TB
zh: '| `1.9.1` | `0.9.1` | `>=3.6`, `<=3.9` |'
- en: '| `1.8.1` | `0.8.1` | `>=3.6`, `<=3.9` |'
id: totrans-54
prefs: []
type: TYPE_TB
zh: '| `1.8.1` | `0.8.1` | `>=3.6`, `<=3.9` |'
- en: '| `1.7.1` | `0.7.2` | `>=3.6`, `<=3.9` |'
id: totrans-55
prefs: []
type: TYPE_TB
zh: '| `1.7.1` | `0.7.2` | `>=3.6`, `<=3.9` |'
- en: '| `1.7.0` | `0.7.0` | `>=3.6`, `<=3.8` |'
id: totrans-56
prefs: []
type: TYPE_TB
zh: '| `1.7.0` | `0.7.0` | `>=3.6`, `<=3.8` |'
- en: '| `1.6.0` | `0.6.0` | `>=3.6`, `<=3.8` |'
id: totrans-57
prefs: []
type: TYPE_TB
zh: '| `1.6.0` | `0.6.0` | `>=3.6`, `<=3.8` |'
- en: '| `1.5.0` | `0.5.0` | `>=3.5`, `<=3.8` |'
id: totrans-58
prefs: []
type: TYPE_TB
zh: '| `1.5.0` | `0.5.0` | `>=3.5`, `<=3.8` |'
- en: '| `1.4.0` | `0.4.0` | `==2.7`, `>=3.5`, `<=3.8` |'
id: totrans-59
prefs: []
type: TYPE_TB
zh: '| `1.4.0` | `0.4.0` | `==2.7`, `>=3.5`, `<=3.8` |'
- en: Building from source
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 从源代码构建
- en: 原文:[https://pytorch.org/audio/stable/build.html](https://pytorch.org/audio/stable/build.html)
id: totrans-1
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/audio/stable/build.html](https://pytorch.org/audio/stable/build.html)
- en: TorchAudio integrates PyTorch for numerical computation and third party libraries
for multimedia I/O. It requires the following tools to build from source.
id: totrans-2
prefs: []
type: TYPE_NORMAL
zh: TorchAudio集成了PyTorch进行数值计算和第三方库进行多媒体I/O。构建源代码需要以下工具。
- en: '[PyTorch](https://pytorch.org)'
id: totrans-3
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[PyTorch](https://pytorch.org)'
- en: '[CMake](https://cmake.org/)'
id: totrans-4
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[CMake](https://cmake.org/)'
- en: '[Ninja](https://ninja-build.org/)'
id: totrans-5
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[Ninja](https://ninja-build.org/)'
- en: C++ complier with C++ 17 support
id: totrans-6
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: 具有C++ 17支持的C++编译器
- en: '[GCC](https://gcc.gnu.org/) (Linux)'
id: totrans-7
prefs:
- PREF_IND
- PREF_UL
type: TYPE_NORMAL
zh: '[GCC](https://gcc.gnu.org/)(Linux)'
- en: '[Clang](https://clang.llvm.org/) (macOS)'
id: totrans-8
prefs:
- PREF_IND
- PREF_UL
type: TYPE_NORMAL
zh: '[Clang](https://clang.llvm.org/)(macOS)'
- en: '[MSVC](https://visualstudio.microsoft.com) 2019 or newer (Windows)'
id: totrans-9
prefs:
- PREF_IND
- PREF_UL
type: TYPE_NORMAL
zh: '[MSVC](https://visualstudio.microsoft.com) 2019或更新版本(Windows)'
- en: '[CUDA toolkit](https://developer.nvidia.com/cudnn) and [cuDNN](https://developer.nvidia.com/cudnn)
(if building CUDA extension)'
id: totrans-10
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[CUDA工具包](https://developer.nvidia.com/cudnn)和[cuDNN](https://developer.nvidia.com/cudnn)(如果构建CUDA扩展)'
- en: Most of the tools are available in [Conda](https://conda.io/), so we recommend
using conda.
id: totrans-11
prefs: []
type: TYPE_NORMAL
zh: 大多数工具都可以在[Conda](https://conda.io/)中找到,因此我们建议使用conda。
- en: '[Building on Linux and macOS](build.linux.html)'
id: totrans-12
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[在Linux和macOS上构建](build.linux.html)'
- en: '[Building on Windows](build.windows.html)'
id: totrans-13
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[在Windows上构建](build.windows.html)'
- en: '[Building on Jetson](build.jetson.html)'
id: totrans-14
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[在Jetson上构建](build.jetson.html)'
- en: Customizing the build[](#customizing-the-build "Permalink to this heading")
id: totrans-15
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 自定义构建[](#customizing-the-build "Permalink to this heading")
- en: TorchAudio’s integration with third party libraries can be enabled/disabled
via environment variables.
id: totrans-16
prefs: []
type: TYPE_NORMAL
zh: 通过环境变量可以启用/禁用TorchAudio与第三方库的集成。
- en: They can be enabled by passing `1` and disabled by `0`.
id: totrans-17
prefs: []
type: TYPE_NORMAL
zh: 可以通过传递`1`来启用,通过`0`来禁用。
- en: '`BUILD_SOX`: Enable/disable I/O features based on libsox.'
id: totrans-18
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '`BUILD_SOX`: 基于libsox的I/O功能的启用/禁用。'
- en: '`BUILD_KALDI`: Enable/disable feature extraction based on Kaldi.'
id: totrans-19
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '`BUILD_KALDI`: 基于Kaldi的特征提取的启用/禁用。'
- en: '`BUILD_RNNT`: Enable/disable custom RNN-T loss function.'
id: totrans-20
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '`BUILD_RNNT`: 启用/禁用自定义RNN-T损失函数。'
- en: '`USE_FFMPEG`: Enable/disable I/O features based on FFmpeg libraries.'
id: totrans-21
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '`USE_FFMPEG`: 基于FFmpeg库的I/O功能的启用/禁用。'
- en: '`USE_ROCM`: Enable/disable AMD ROCm support.'
id: totrans-22
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '`USE_ROCM`: 启用/禁用AMD ROCm支持。'
- en: '`USE_CUDA`: Enable/disable CUDA support.'
id: totrans-23
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '`USE_CUDA`: 启用/禁用CUDA支持。'
- en: For the latest configurations and their default values, please check the source
code. [https://github.com/pytorch/audio/blob/main/tools/setup_helpers/extension.py](https://github.com/pytorch/audio/blob/main/tools/setup_helpers/extension.py)
id: totrans-24
prefs: []
type: TYPE_NORMAL
zh: 有关最新配置及其默认值,请查看源代码。[https://github.com/pytorch/audio/blob/main/tools/setup_helpers/extension.py](https://github.com/pytorch/audio/blob/main/tools/setup_helpers/extension.py)
- en: Building on Linux and macOS
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 在Linux和macOS上构建
- en: 原文:[https://pytorch.org/audio/stable/build.linux.html](https://pytorch.org/audio/stable/build.linux.html)
id: totrans-1
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/audio/stable/build.linux.html](https://pytorch.org/audio/stable/build.linux.html)
- en: 1\. Install Conda and activate conda environment[](#install-conda-and-activate-conda-environment
"Permalink to this heading")
id: totrans-2
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 1\. 安装Conda并激活conda环境[](#install-conda-and-activate-conda-environment "此标题的永久链接")
- en: Please folllow the instruction at [https://docs.conda.io/en/latest/miniconda.html](https://docs.conda.io/en/latest/miniconda.html)
id: totrans-3
prefs: []
type: TYPE_NORMAL
zh: 请按照[https://docs.conda.io/en/latest/miniconda.html](https://docs.conda.io/en/latest/miniconda.html)上的说明操作
- en: 2\. Install PyTorch[](#install-pytorch "Permalink to this heading")
id: totrans-4
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 2\. 安装PyTorch[](#install-pytorch "此标题的永久链接")
- en: Please select the version of PyTorch you want to install from [https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/)
id: totrans-5
prefs: []
type: TYPE_NORMAL
zh: 请从[https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/)选择要安装的PyTorch版本
- en: Here, we install nightly build.
id: totrans-6
prefs: []
type: TYPE_NORMAL
zh: 在这里,我们安装夜间构建。
- en: '[PRE0]'
id: totrans-7
prefs: []
type: TYPE_PRE
zh: '[PRE0]'
- en: 3\. Install build tools[](#install-build-tools "Permalink to this heading")
id: totrans-8
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 3\. 安装构建工具[](#install-build-tools "此标题的永久链接")
- en: '[PRE1]'
id: totrans-9
prefs: []
type: TYPE_PRE
zh: '[PRE1]'
- en: 4\. Clone the torchaudio repository[](#clone-the-torchaudio-repository "Permalink
to this heading")
id: totrans-10
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 4\. 克隆torchaudio存储库[](#clone-the-torchaudio-repository "此标题的永久链接")
- en: '[PRE2]'
id: totrans-11
prefs: []
type: TYPE_PRE
zh: '[PRE2]'
- en: 5\. Build[](#build "Permalink to this heading")
id: totrans-12
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 5\. 构建[](#build "此标题的永久链接")
- en: '[PRE3]'
id: totrans-13
prefs: []
type: TYPE_PRE
zh: '[PRE3]'
- en: Note
id: totrans-14
prefs: []
type: TYPE_NORMAL
zh: 注意
- en: Due to the complexity of build process, TorchAudio only supports in-place build.
To use `pip`, please use `--no-use-pep517` option.
id: totrans-15
prefs: []
type: TYPE_NORMAL
zh: 由于构建过程的复杂性,TorchAudio仅支持原地构建。要使用`pip`,请使用`--no-use-pep517`选项。
- en: '`pip install -v -e . --no-use-pep517`'
id: totrans-16
prefs: []
type: TYPE_NORMAL
zh: '`pip install -v -e . --no-use-pep517`'
- en: '[Optional] Build TorchAudio with a custom built FFmpeg[](#optional-build-torchaudio-with-a-custom-built-ffmpeg
"Permalink to this heading")'
id: totrans-17
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: '[可选] 使用自定义构建的FFmpeg构建TorchAudio[](#optional-build-torchaudio-with-a-custom-built-ffmpeg
"此标题的永久链接")'
- en: By default, torchaudio tries to build FFmpeg extension with support for multiple
FFmpeg versions. This process uses pre-built FFmpeg libraries compiled for specific
CPU architectures like `x86_64` and `aarch64` (`arm64`).
id: totrans-18
prefs: []
type: TYPE_NORMAL
zh: 默认情况下,torchaudio尝试构建支持多个FFmpeg版本的FFmpeg扩展。此过程使用为特定CPU架构(如`x86_64`和`aarch64`(`arm64`))编译的预构建FFmpeg库。
- en: If your CPU is not one of those, then the build process can fail. To workaround,
one can disable FFmpeg integration (by setting the environment variable `USE_FFMPEG=0`)
or switch to the single version FFmpeg extension.
id: totrans-19
prefs: []
type: TYPE_NORMAL
zh: 如果您的CPU不是其中之一,则构建过程可能会失败。为了解决问题,可以禁用FFmpeg集成(通过设置环境变量`USE_FFMPEG=0`)或切换到单版本FFmpeg扩展。
- en: To build single version FFmpeg extension, FFmpeg binaries must be provided by
user and available in the build environment. To do so, install FFmpeg and set
`FFMPEG_ROOT` environment variable to specify the location of FFmpeg.
id: totrans-20
prefs: []
type: TYPE_NORMAL
zh: 要构建单版本FFmpeg扩展,用户必须提供FFmpeg二进制文件,并在构建环境中可用。为此,请安装FFmpeg并设置`FFMPEG_ROOT`环境变量以指定FFmpeg的位置。
- en: '[PRE4]'
id: totrans-21
prefs: []
type: TYPE_PRE
zh: '[PRE4]'
此差异已折叠。
- en: Building on Jetson
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 在Jetson上构建
- en: 原文:[https://pytorch.org/audio/stable/build.jetson.html](https://pytorch.org/audio/stable/build.jetson.html)
id: totrans-1
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/audio/stable/build.jetson.html](https://pytorch.org/audio/stable/build.jetson.html)
- en: 1\. Install JetPack[](#install-jetpack "Permalink to this heading")
id: totrans-2
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 1\. 安装JetPack[](#install-jetpack "Permalink to this heading")
- en: JetPack includes the collection of CUDA-related libraries that is required to
run PyTorch with CUDA.
id: totrans-3
prefs: []
type: TYPE_NORMAL
zh: JetPack包括了运行带有CUDA的PyTorch所需的CUDA相关库的集合。
- en: Please refer to [https://developer.nvidia.com/embedded/learn/get-started-jetson-agx-orin-devkit](https://developer.nvidia.com/embedded/learn/get-started-jetson-agx-orin-devkit)
for the up-to-date instruction.
id: totrans-4
prefs: []
type: TYPE_NORMAL
zh: 请参考[https://developer.nvidia.com/embedded/learn/get-started-jetson-agx-orin-devkit](https://developer.nvidia.com/embedded/learn/get-started-jetson-agx-orin-devkit)获取最新的指导。
- en: '[PRE0]'
id: totrans-5
prefs: []
type: TYPE_PRE
zh: '[PRE0]'
- en: Checking the versions[](#checking-the-versions "Permalink to this heading")
id: totrans-6
prefs:
- PREF_H3
type: TYPE_NORMAL
zh: 检查版本[](#checking-the-versions "Permalink to this heading")
- en: To check the version installed you can use the following commands;
id: totrans-7
prefs: []
type: TYPE_NORMAL
zh: 要检查已安装的版本,可以使用以下命令;
- en: '[PRE1]'
id: totrans-8
prefs: []
type: TYPE_PRE
zh: '[PRE1]'
- en: '[![https://download.pytorch.org/torchaudio/doc-assets/jetson-package-versions.png](../Images/510d69555d6f8cadc50c29ad61243630.png)](https://download.pytorch.org/torchaudio/doc-assets/jetson-package-versions.png)'
id: totrans-9
prefs: []
type: TYPE_NORMAL
zh: '[![https://download.pytorch.org/torchaudio/doc-assets/jetson-package-versions.png](../Images/510d69555d6f8cadc50c29ad61243630.png)](https://download.pytorch.org/torchaudio/doc-assets/jetson-package-versions.png)'
- en: 2\. [Optional] Install jtop[](#optional-install-jtop "Permalink to this heading")
id: totrans-10
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 2\. [可选] 安装jtop[](#optional-install-jtop "Permalink to this heading")
- en: Since Tegra GPUs are not supported by `nvidia-smi` command, it is recommended
to isntall `jtop`.
id: totrans-11
prefs: []
type: TYPE_NORMAL
zh: 由于`nvidia-smi`命令不支持Tegra GPU,建议安装`jtop`。
- en: Only super-use can install `jtop`. So make sure to add `-U`, so that running
`jtop` won’t require super-user priviledge.
id: totrans-12
prefs: []
type: TYPE_NORMAL
zh: 只有超级用户才能安装`jtop`。因此,请确保添加`-U`,这样运行`jtop`不需要超级用户权限。
- en: 3\. Install `pip` in user env[](#install-pip-in-user-env "Permalink to this
heading")
id: totrans-13
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 3\. 在用户环境中安装`pip`[](#install-pip-in-user-env "Permalink to this heading")
- en: By default, `pip` / `pip3` commands use the ones from system directory `/usr/bin/`,
and its `site-packages` directory is protected and cannot be modified without
`sudo`.
id: totrans-14
prefs: []
type: TYPE_NORMAL
zh: 默认情况下,`pip` / `pip3`命令使用系统目录`/usr/bin/`中的命令,并且其`site-packages`目录受保护,无法在没有`sudo`的情况下修改。
- en: One way to workaround this is to install `pip` in user directory.
id: totrans-15
prefs: []
type: TYPE_NORMAL
zh: 解决此问题的一种方法是在用户目录中安装`pip`。
- en: '[https://forums.developer.nvidia.com/t/python-3-module-install-folder/181321](https://forums.developer.nvidia.com/t/python-3-module-install-folder/181321)'
id: totrans-16
prefs: []
type: TYPE_NORMAL
zh: '[https://forums.developer.nvidia.com/t/python-3-module-install-folder/181321](https://forums.developer.nvidia.com/t/python-3-module-install-folder/181321)'
- en: '[PRE2]'
id: totrans-17
prefs: []
type: TYPE_PRE
zh: '[PRE2]'
- en: After this verify that `pip` command is pointing the one in user directory.
id: totrans-18
prefs: []
type: TYPE_NORMAL
zh: 之后,请验证`pip`命令是否指向用户目录中的命令。
- en: '[PRE3]'
id: totrans-19
prefs: []
type: TYPE_PRE
zh: '[PRE3]'
- en: 4\. Install PyTorch[](#install-pytorch "Permalink to this heading")
id: totrans-20
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 4\. 安装PyTorch[](#install-pytorch "Permalink to this heading")
- en: As of PyTorch 1.13 and torchaudio 0.13, there is no official pre-built binaries
for Linux ARM64\. Nidia provides custom pre-built binaries for PyTorch, which
works with specific JetPack.
id: totrans-21
prefs: []
type: TYPE_NORMAL
zh: 截至PyTorch 1.13和torchaudio 0.13,Linux ARM64没有官方预构建的二进制文件。Nidia提供了适用于特定JetPack的自定义预构建的PyTorch二进制文件。
- en: Please refer to [https://docs.nvidia.com/deeplearning/frameworks/install-pytorch-jetson-platform/index.html](https://docs.nvidia.com/deeplearning/frameworks/install-pytorch-jetson-platform/index.html)
for up-to-date instruction on how to install PyTorch.
id: totrans-22
prefs: []
type: TYPE_NORMAL
zh: 请参考[https://docs.nvidia.com/deeplearning/frameworks/install-pytorch-jetson-platform/index.html](https://docs.nvidia.com/deeplearning/frameworks/install-pytorch-jetson-platform/index.html)获取有关如何安装PyTorch的最新指导。
- en: '[PRE4]'
id: totrans-23
prefs: []
type: TYPE_PRE
zh: '[PRE4]'
- en: Verify the installation by checking the version and CUDA device accessibility.
id: totrans-24
prefs: []
type: TYPE_NORMAL
zh: 通过检查版本和CUDA设备的可访问性来验证安装。
- en: '[PRE5]'
id: totrans-25
prefs: []
type: TYPE_PRE
zh: '[PRE5]'
- en: '[![https://download.pytorch.org/torchaudio/doc-assets/jetson-torch.png](../Images/a3a5fbe3614beb0175742530a928b956.png)](https://download.pytorch.org/torchaudio/doc-assets/jetson-torch.png)'
id: totrans-26
prefs: []
type: TYPE_NORMAL
zh: '[![https://download.pytorch.org/torchaudio/doc-assets/jetson-torch.png](../Images/a3a5fbe3614beb0175742530a928b956.png)](https://download.pytorch.org/torchaudio/doc-assets/jetson-torch.png)'
- en: 5\. Build TorchAudio[](#build-torchaudio "Permalink to this heading")
id: totrans-27
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 5\. 构建TorchAudio[](#build-torchaudio "Permalink to this heading")
- en: 1\. Install build tools[](#install-build-tools "Permalink to this heading")
id: totrans-28
prefs:
- PREF_H3
type: TYPE_NORMAL
zh: 1\. 安装构建工具[](#install-build-tools "Permalink to this heading")
- en: '[PRE6]'
id: totrans-29
prefs: []
type: TYPE_PRE
zh: '[PRE6]'
- en: 2\. Install dependencies[](#install-dependencies "Permalink to this heading")
id: totrans-30
prefs:
- PREF_H3
type: TYPE_NORMAL
zh: 2\. 安装依赖项[](#install-dependencies "Permalink to this heading")
- en: '[PRE7]'
id: totrans-31
prefs: []
type: TYPE_PRE
zh: '[PRE7]'
- en: 3\. Build TorchAudio[](#id1 "Permalink to this heading")
id: totrans-32
prefs:
- PREF_H3
type: TYPE_NORMAL
zh: 3\. 构建TorchAudio[](#id1 "Permalink to this heading")
- en: '[PRE8]'
id: totrans-33
prefs: []
type: TYPE_PRE
zh: '[PRE8]'
- en: 4\. Check the installation[](#check-the-installation "Permalink to this heading")
id: totrans-34
prefs:
- PREF_H3
type: TYPE_NORMAL
zh: 4\. 检查安装[](#check-the-installation "Permalink to this heading")
- en: '[PRE9]'
id: totrans-35
prefs: []
type: TYPE_PRE
zh: '[PRE9]'
- en: '[PRE10]'
id: totrans-36
prefs: []
type: TYPE_PRE
zh: '[PRE10]'
- en: '[![https://download.pytorch.org/torchaudio/doc-assets/jetson-verify-build.png](../Images/54e00283b6bc33749b45ed29bb75ce91.png)](https://download.pytorch.org/torchaudio/doc-assets/jetson-verify-build.png)'
id: totrans-37
prefs: []
type: TYPE_NORMAL
zh: '[![https://download.pytorch.org/torchaudio/doc-assets/jetson-verify-build.png](../Images/54e00283b6bc33749b45ed29bb75ce91.png)](https://download.pytorch.org/torchaudio/doc-assets/jetson-verify-build.png)'
- en: Enabling GPU video decoder/encoder
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 启用GPU视频解码器/编码器
- en: 原文:[https://pytorch.org/audio/stable/build.ffmpeg.html](https://pytorch.org/audio/stable/build.ffmpeg.html)
id: totrans-1
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/audio/stable/build.ffmpeg.html](https://pytorch.org/audio/stable/build.ffmpeg.html)
- en: TorchAudio can make use of hardware-based video decoding and encoding supported
by underlying FFmpeg libraries that are linked at runtime.
id: totrans-2
prefs: []
type: TYPE_NORMAL
zh: TorchAudio可以利用底层FFmpeg库支持的硬件解码和编码功能。
- en: Using NVIDIA’s GPU decoder and encoder, it is also possible to pass around CUDA
Tensor directly, that is decode video into CUDA tensor or encode video from CUDA
tensor, without moving data from/to CPU.
id: totrans-3
prefs: []
type: TYPE_NORMAL
zh: 使用NVIDIA的GPU解码器和编码器,还可以直接传递CUDA Tensor,即将视频解码为CUDA张量或从CUDA张量编码视频,而无需在CPU之间移动数据。
- en: This improves the video throughput significantly. However, please note that
not all the video formats are supported by hardware acceleration.
id: totrans-4
prefs: []
type: TYPE_NORMAL
zh: 这将显著提高视频吞吐量。但请注意,并非所有视频格式都支持硬件加速。
- en: This page goes through how to build FFmpeg with hardware acceleration. For the
detail on the performance of GPU decoder and encoder please see [NVDEC tutoial](tutorials/nvdec_tutorial.html#nvdec-tutorial)
and [NVENC tutorial](tutorials/nvenc_tutorial.html#nvenc-tutorial).
id: totrans-5
prefs: []
type: TYPE_NORMAL
zh: 本页介绍了如何使用硬件加速构建FFmpeg。有关GPU解码器和编码器性能的详细信息,请参阅[NVDEC教程](tutorials/nvdec_tutorial.html#nvdec-tutorial)和[NVENC教程](tutorials/nvenc_tutorial.html#nvenc-tutorial)。
- en: Overview[](#overview "Permalink to this heading")
id: totrans-6
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 概述[](#overview "跳转到此标题")
- en: Using them in TorchAduio requires additional FFmpeg configuration.
id: totrans-7
prefs: []
type: TYPE_NORMAL
zh: 在TorchAudio中使用它们需要额外的FFmpeg配置。
- en: In the following, we look into how to enable GPU video decoding with [NVIDIA’s
Video codec SDK](https://developer.nvidia.com/nvidia-video-codec-sdk). To use
NVENC/NVDEC with TorchAudio, the following items are required.
id: totrans-8
prefs: []
type: TYPE_NORMAL
zh: 接下来,我们将研究如何使用[NVIDIA的视频编解码SDK](https://developer.nvidia.com/nvidia-video-codec-sdk)启用GPU视频解码。要在TorchAudio中使用NVENC/NVDEC,需要以下项目。
- en: NVIDIA GPU with hardware video decoder/encoder.
id: totrans-9
prefs:
- PREF_OL
type: TYPE_NORMAL
zh: 具有硬件视频解码器/编码器的NVIDIA GPU。
- en: FFmpeg libraries compiled with NVDEC/NVENC support. †
id: totrans-10
prefs:
- PREF_OL
type: TYPE_NORMAL
zh: 使用已编译具有NVDEC/NVENC支持的FFmpeg库。†
- en: PyTorch / TorchAudio with CUDA support.
id: totrans-11
prefs:
- PREF_OL
type: TYPE_NORMAL
zh: 带有CUDA支持的PyTorch / TorchAudio。
- en: TorchAudio’s official binary distributions are compiled to work with FFmpeg
libraries, and they contain the logic to use hardware decoding/encoding.
id: totrans-12
prefs: []
type: TYPE_NORMAL
zh: TorchAudio的官方二进制发行版已经编译为与FFmpeg库配合使用,并包含使用硬件解码/编码的逻辑。
- en: In the following, we build FFmpeg 4 libraries with NVDEC/NVENC support. You
can also use FFmpeg 5 or 6.
id: totrans-13
prefs: []
type: TYPE_NORMAL
zh: 接下来,我们使用NVDEC/NVENC支持构建FFmpeg 4库。您也可以使用FFmpeg 5或6。
- en: The following procedure was tested on Ubuntu.
id: totrans-14
prefs: []
type: TYPE_NORMAL
zh: 以下过程在Ubuntu上进行了测试。
- en: † For details on NVDEC/NVENC and FFmpeg, please refer to the following articles.
id: totrans-15
prefs: []
type: TYPE_NORMAL
zh: †有关NVDEC/NVENC和FFmpeg的详细信息,请参考以下文章。
- en: '[https://docs.nvidia.com/video-technologies/video-codec-sdk/11.1/nvdec-video-decoder-api-prog-guide/](https://docs.nvidia.com/video-technologies/video-codec-sdk/11.1/nvdec-video-decoder-api-prog-guide/)'
id: totrans-16
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[https://docs.nvidia.com/video-technologies/video-codec-sdk/11.1/nvdec-video-decoder-api-prog-guide/](https://docs.nvidia.com/video-technologies/video-codec-sdk/11.1/nvdec-video-decoder-api-prog-guide/)'
- en: '[https://docs.nvidia.com/video-technologies/video-codec-sdk/11.1/ffmpeg-with-nvidia-gpu/index.html#compiling-ffmpeg](https://docs.nvidia.com/video-technologies/video-codec-sdk/11.1/ffmpeg-with-nvidia-gpu/index.html#compiling-ffmpeg)'
id: totrans-17
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[https://docs.nvidia.com/video-technologies/video-codec-sdk/11.1/ffmpeg-with-nvidia-gpu/index.html#compiling-ffmpeg](https://docs.nvidia.com/video-technologies/video-codec-sdk/11.1/ffmpeg-with-nvidia-gpu/index.html#compiling-ffmpeg)'
- en: '[https://developer.nvidia.com/blog/nvidia-ffmpeg-transcoding-guide/](https://developer.nvidia.com/blog/nvidia-ffmpeg-transcoding-guide/)'
id: totrans-18
prefs:
- PREF_UL
type: TYPE_NORMAL
zh: '[https://developer.nvidia.com/blog/nvidia-ffmpeg-transcoding-guide/](https://developer.nvidia.com/blog/nvidia-ffmpeg-transcoding-guide/)'
- en: Check the GPU and CUDA version[](#check-the-gpu-and-cuda-version "Permalink
to this heading")
id: totrans-19
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 检查GPU和CUDA版本[](#check-the-gpu-and-cuda-version "跳转到此标题")
- en: First, check the available GPU. Here, we have Tesla T4 with CUDA Toolkit 11.2
installed.
id: totrans-20
prefs: []
type: TYPE_NORMAL
zh: 首先,检查可用的GPU。这里,我们有安装了CUDA Toolkit 11.2的Tesla T4。
- en: '[PRE0]'
id: totrans-21
prefs: []
type: TYPE_PRE
zh: '[PRE0]'
- en: Checking the compute capability[](#checking-the-compute-capability "Permalink
to this heading")
id: totrans-22
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 检查计算能力[](#checking-the-compute-capability "跳转到此标题")
- en: Later, we need the version of compute capability supported by this GPU. The
following page lists the GPUs and corresponding compute capabilities. The compute
capability of T4 is `7.5`.
id: totrans-23
prefs: []
type: TYPE_NORMAL
zh: 稍后,我们需要此GPU支持的计算能力版本。以下页面列出了GPU及其对应的计算能力。T4的计算能力为`7.5`。
- en: '[https://developer.nvidia.com/cuda-gpus](https://developer.nvidia.com/cuda-gpus)'
id: totrans-24
prefs: []
type: TYPE_NORMAL
zh: '[https://developer.nvidia.com/cuda-gpus](https://developer.nvidia.com/cuda-gpus)'
- en: Install NVIDIA Video Codec Headers[](#install-nvidia-video-codec-headers "Permalink
to this heading")
id: totrans-25
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 安装NVIDIA视频编解码头文件[](#install-nvidia-video-codec-headers "跳转到此标题")
- en: To build FFmpeg with NVDEC/NVENC, we first need to install the headers that
FFmpeg uses to interact with Video Codec SDK.
id: totrans-26
prefs: []
type: TYPE_NORMAL
zh: 要构建具有NVDEC/NVENC的FFmpeg,我们首先需要安装FFmpeg用于与视频编解码SDK交互的头文件。
- en: Since we have CUDA 11 working in the system, we use one of `n11` tag.
id: totrans-27
prefs: []
type: TYPE_NORMAL
zh: 由于系统中已经安装了CUDA 11,我们使用了`n11`标签之一。
- en: '[PRE1]'
id: totrans-28
prefs: []
type: TYPE_PRE
zh: '[PRE1]'
- en: The location of installation can be changed with `make PREFIX=<DESIRED_DIRECTORY>
install`.
id: totrans-29
prefs: []
type: TYPE_NORMAL
zh: 安装位置可以使用`make PREFIX=<DESIRED_DIRECTORY> install`进行更改。
- en: '[PRE2]'
id: totrans-30
prefs: []
type: TYPE_PRE
zh: '[PRE2]'
- en: Install FFmpeg dependencies[](#install-ffmpeg-dependencies "Permalink to this
heading")
id: totrans-31
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 安装FFmpeg依赖项[](#install-ffmpeg-dependencies "跳转到此标题")
- en: Next, we install tools and libraries required during the FFmpeg build. The minimum
requirement is [Yasm](https://yasm.tortall.net/). Here we additionally install
H264 video codec and HTTPS protocol, which we use later for verifying the installation.
id: totrans-32
prefs: []
type: TYPE_NORMAL
zh: 接下来,我们安装在FFmpeg构建过程中所需的工具和库。最低要求是[Yasm](https://yasm.tortall.net/)。在这里,我们还安装了H264视频编解码器和HTTPS协议,稍后我们将用于验证安装。
- en: '[PRE3]'
id: totrans-33
prefs: []
type: TYPE_PRE
zh: '[PRE3]'
- en: '[PRE4]'
id: totrans-34
prefs: []
type: TYPE_PRE
zh: '[PRE4]'
- en: Build FFmpeg with NVDEC/NVENC support[](#build-ffmpeg-with-nvdec-nvenc-support
"Permalink to this heading")
id: totrans-35
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 构建具有NVDEC/NVENC支持的FFmpeg[](#build-ffmpeg-with-nvdec-nvenc-support "跳转到此标题")
- en: Next we download the source code of FFmpeg 4\. We use 4.4.2 here.
id: totrans-36
prefs: []
type: TYPE_NORMAL
zh: 接下来,我们下载FFmpeg 4的源代码。这里我们使用的是4.4.2版本。
- en: '[PRE5]'
id: totrans-37
prefs: []
type: TYPE_PRE
zh: '[PRE5]'
- en: 'Next we configure FFmpeg build. Note the following:'
id: totrans-38
prefs: []
type: TYPE_NORMAL
zh: 接下来我们配置FFmpeg构建。请注意以下内容:
- en: We provide flags like `-I/usr/local/cuda/include`, `-L/usr/local/cuda/lib64`
to let the build process know where the CUDA libraries are found.
id: totrans-39
prefs:
- PREF_OL
type: TYPE_NORMAL
zh: 我们提供像`-I/usr/local/cuda/include`、`-L/usr/local/cuda/lib64`这样的标志,让构建过程知道CUDA库的位置。
- en: We provide flags like `--enable-nvdec` and `--enable-nvenc` to enable NVDEC/NVENC.
id: totrans-40
prefs:
- PREF_OL
type: TYPE_NORMAL
zh: 我们提供像`--enable-nvdec`和`--enable-nvenc`这样的标志来启用NVDEC/NVENC。
- en: We also provide NVCC flags with compute capability `75`, which corresponds to
`7.5` of T4\. †
id: totrans-41
prefs:
- PREF_OL
type: TYPE_NORMAL
zh: 我们还提供了带有计算能力`75`的NVCC标志,对应于T4的`7.5`。
- en: We install the library in `/usr/lib/`.
id: totrans-42
prefs:
- PREF_OL
type: TYPE_NORMAL
zh: 我们将库安装在`/usr/lib/`中。
- en: Note
id: totrans-43
prefs: []
type: TYPE_NORMAL
zh: 注意
- en: † The configuration script verifies NVCC by compiling a sample code. By default
it uses old compute capability such as `30`, which is no longer supported by CUDA
11\. So it is required to set a correct compute capability.
id: totrans-44
prefs: []
type: TYPE_NORMAL
zh: †配置脚本通过编译示例代码来验证NVCC。默认情况下,它使用旧的计算能力,例如`30`,这在CUDA 11中不再受支持。因此,需要设置正确的计算能力。
- en: '[PRE6]'
id: totrans-45
prefs: []
type: TYPE_PRE
zh: '[PRE6]'
- en: '[PRE7]'
id: totrans-46
prefs: []
type: TYPE_PRE
zh: '[PRE7]'
- en: Now we build and install
id: totrans-47
prefs: []
type: TYPE_NORMAL
zh: 现在我们构建并安装
- en: '[PRE8]'
id: totrans-48
prefs: []
type: TYPE_PRE
zh: '[PRE8]'
- en: '[PRE9]'
id: totrans-49
prefs: []
type: TYPE_PRE
zh: '[PRE9]'
- en: Checking the intallation[](#checking-the-intallation "Permalink to this heading")
id: totrans-50
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 检查安装
- en: To verify that the FFmpeg we built have CUDA support, we can check the list
of available decoders and encoders.
id: totrans-51
prefs: []
type: TYPE_NORMAL
zh: 要验证我们构建的FFmpeg是否支持CUDA,我们可以检查可用解码器和编码器的列表。
- en: '[PRE10]'
id: totrans-52
prefs: []
type: TYPE_PRE
zh: '[PRE10]'
- en: '[PRE11]'
id: totrans-53
prefs: []
type: TYPE_PRE
zh: '[PRE11]'
- en: '[PRE12]'
id: totrans-54
prefs: []
type: TYPE_PRE
zh: '[PRE12]'
- en: '[PRE13]'
id: totrans-55
prefs: []
type: TYPE_PRE
zh: '[PRE13]'
- en: The following command fetches video from remote server, decode with NVDEC (cuvid)
and re-encode with NVENC. If this command does not work, then there is an issue
with FFmpeg installation, and TorchAudio would not be able to use them either.
id: totrans-56
prefs: []
type: TYPE_NORMAL
zh: 以下命令从远程服务器获取视频,使用NVDEC(cuvid)解码,然后使用NVENC重新编码。如果此命令不起作用,则说明FFmpeg安装存在问题,TorchAudio也无法使用它们。
- en: '[PRE14]'
id: totrans-57
prefs: []
type: TYPE_PRE
zh: '[PRE14]'
- en: 'Note that there is `Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> h264 (h264_nvenc))`,
which means that video is decoded with `h264_cuvid` decoder and `h264_nvenc` encoder.'
id: totrans-58
prefs: []
type: TYPE_NORMAL
zh: '请注意,存在`Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> h264 (h264_nvenc))`,这意味着视频使用`h264_cuvid`解码器和`h264_nvenc`编码器进行解码。'
- en: '[PRE15]'
id: totrans-59
prefs: []
type: TYPE_PRE
zh: '[PRE15]'
- en: Using the GPU decoder/encoder from TorchAudio[](#using-the-gpu-decoder-encoder-from-torchaudio
"Permalink to this heading")
id: totrans-60
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 使用TorchAudio的GPU解码器/编码器
- en: Checking the installation[](#checking-the-installation "Permalink to this heading")
id: totrans-61
prefs:
- PREF_H3
type: TYPE_NORMAL
zh: 检查安装
- en: Once the FFmpeg is properly working with hardware acceleration, we need to check
if TorchAudio can pick it up correctly.
id: totrans-62
prefs: []
type: TYPE_NORMAL
zh: 一旦FFmpeg正确使用硬件加速,我们需要检查TorchAudio是否能够正确识别它。
- en: There are utility functions to query the capability of FFmpeg in [`torchaudio.utils.ffmpeg_utils`](generated/torchaudio.utils.ffmpeg_utils.html#module-torchaudio.utils.ffmpeg_utils
"torchaudio.utils.ffmpeg_utils").
id: totrans-63
prefs: []
type: TYPE_NORMAL
zh: 在[`torchaudio.utils.ffmpeg_utils`](generated/torchaudio.utils.ffmpeg_utils.html#module-torchaudio.utils.ffmpeg_utils
"torchaudio.utils.ffmpeg_utils")中有用于查询FFmpeg功能的实用函数。
- en: You can first use [`get_video_decoders()`](generated/torchaudio.utils.ffmpeg_utils.html#torchaudio.utils.ffmpeg_utils.get_video_decoders
"torchaudio.utils.ffmpeg_utils.get_video_decoders") and [`get_video_encoders()`](generated/torchaudio.utils.ffmpeg_utils.html#torchaudio.utils.ffmpeg_utils.get_video_encoders
"torchaudio.utils.ffmpeg_utils.get_video_encoders") to check if GPU decoders and
encoders (such as `h264_cuvid` and `h264_nvenc`) are listed.
id: totrans-64
prefs: []
type: TYPE_NORMAL
zh: 您可以首先使用[`get_video_decoders()`](generated/torchaudio.utils.ffmpeg_utils.html#torchaudio.utils.ffmpeg_utils.get_video_decoders
"torchaudio.utils.ffmpeg_utils.get_video_decoders")和[`get_video_encoders()`](generated/torchaudio.utils.ffmpeg_utils.html#torchaudio.utils.ffmpeg_utils.get_video_encoders
"torchaudio.utils.ffmpeg_utils.get_video_encoders")来检查GPU解码器和编码器(如`h264_cuvid`和`h264_nvenc`)是否已列出。
- en: It is often the case where there are multiple FFmpeg installations in the system,
and TorchAudio is loading one different than expected. In such cases, use of `ffmpeg`
to check the installation does not help. You can use functions like [`get_build_config()`](generated/torchaudio.utils.ffmpeg_utils.html#torchaudio.utils.ffmpeg_utils.get_build_config
"torchaudio.utils.ffmpeg_utils.get_build_config") and [`get_versions()`](generated/torchaudio.utils.ffmpeg_utils.html#torchaudio.utils.ffmpeg_utils.get_versions
"torchaudio.utils.ffmpeg_utils.get_versions") to get information about FFmpeg
libraries TorchAudio loaded.
id: totrans-65
prefs: []
type: TYPE_NORMAL
zh: 通常情况下,系统中存在多个FFmpeg安装,TorchAudio加载的可能与预期不同。在这种情况下,使用`ffmpeg`检查安装是无济于事的。您可以使用[`get_build_config()`](generated/torchaudio.utils.ffmpeg_utils.html#torchaudio.utils.ffmpeg_utils.get_build_config
"torchaudio.utils.ffmpeg_utils.get_build_config")和[`get_versions()`](generated/torchaudio.utils.ffmpeg_utils.html#torchaudio.utils.ffmpeg_utils.get_versions
"torchaudio.utils.ffmpeg_utils.get_versions")等函数来获取有关TorchAudio加载的FFmpeg库的信息。
- en: '[PRE16]'
id: totrans-66
prefs: []
type: TYPE_PRE
zh: '[PRE16]'
- en: '[PRE17]'
id: totrans-67
prefs: []
type: TYPE_PRE
zh: '[PRE17]'
- en: Using the hardware decoder and encoder[](#using-the-hardware-decoder-and-encoder
"Permalink to this heading")
id: totrans-68
prefs:
- PREF_H3
type: TYPE_NORMAL
zh: 使用硬件解码器和编码器
- en: Once the installation and the runtime linking work fine, then you can test the
GPU decoding with the following.
id: totrans-69
prefs: []
type: TYPE_NORMAL
zh: 一旦安装和运行时链接正常,您可以使用以下内容测试GPU解码。
- en: For the detail on the performance of GPU decoder and encoder please see [NVDEC
tutoial](tutorials/nvdec_tutorial.html#nvdec-tutorial) and [NVENC tutorial](tutorials/nvenc_tutorial.html#nvenc-tutorial).
id: totrans-70
prefs: []
type: TYPE_NORMAL
zh: 有关GPU解码器和编码器性能的详细信息,请参阅[NVDEC教程](tutorials/nvdec_tutorial.html#nvdec-tutorial)和[NVENC教程](tutorials/nvenc_tutorial.html#nvenc-tutorial)。
- en: API Tutorials
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: API教程
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册