"tests/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "fa71fb447803d269d1050fe5081e2cb577b04b94"
README.md 3.11 KB
Newer Older
fengzch-das's avatar
fengzch-das committed
1
2
3
# <div align="center"><strong>fast_rnnt</strong></div>
## 简介
fast_rnnt 实现了一种更快速、内存效率更高的RNN-T 损失计算方法。
Daniel Povey's avatar
Daniel Povey committed
4

fengzch-das's avatar
fengzch-das committed
5
6
## 安装
组件支持组合
Anton Obukhov's avatar
Anton Obukhov committed
7

fengzch-das's avatar
fengzch-das committed
8
9
10
11
12
   | PyTorch版本 | fastpt版本  |fast_rnnt版本      | DTK版本                  | Python版本       | 推荐编译方式 |
   | ----------- | ----------- | ----------- | ------------------------ | -----------------| ------------ |
   | 2.5.1       | 2.1.0       |master       | >= 25.04                 | 3.8、3.10、3.11  | fastpt不转码 |
   | 2.4.1       | 2.0.1       |master       | >= 25.04                 | 3.8、3.10、3.11  | fastpt不转码 |
   | 其他        | 其他         | 其他        | 其他                     | 3.8、3.10、3.11  | hip转码      |
13

fengzch-das's avatar
fengzch-das committed
14
+ pytorch版本大于2.4.1 && dtk版本大于25.04 推荐使用fastpt不转码编译。
pkufool's avatar
pkufool committed
15

fengzch-das's avatar
fengzch-das committed
16
17
18
19
20
21
22
### 1、使用pip方式安装
fast_rnnt whl包下载目录:[光和开发者社区](https://download.sourcefind.cn:65024/4/main),选择对应的pytorch版本和python版本下载对应fast_rnnt的whl包
```shell
pip install torch* (下载torch的whl包)
pip install fastpt* --no-deps (下载fastpt的whl包)
source  /usr/local/bin/fastpt -E
pip install fast_rnnt* (下载的fast_rnnt的whl包)
pkufool's avatar
pkufool committed
23
```
fengzch-das's avatar
fengzch-das committed
24
### 2、使用源码编译方式安装
pkufool's avatar
pkufool committed
25

fengzch-das's avatar
fengzch-das committed
26
27
#### 编译环境准备
提供基于fastpt不转码编译:
pkufool's avatar
pkufool committed
28

fengzch-das's avatar
fengzch-das committed
29
1. 基于光源pytorch基础镜像环境:镜像下载地址:[光合开发者社区](https://sourcefind.cn/#/image/dcu/pytorch),根据pytorch、python、dtk及系统下载对应的镜像版本。
pkufool's avatar
pkufool committed
30

fengzch-das's avatar
fengzch-das committed
31
32
33
34
35
36
2. 基于现有python环境:安装pytorch,fastpt whl包下载目录:[光合开发者社区](https://sourcefind.cn/#/image/dcu/pytorch),根据python、dtk版本,下载对应pytorch的whl包。安装命令如下:
```shell
pip install torch* (下载torch的whl包)
pip install fastpt* --no-deps (下载fastpt的whl包, 安装顺序,先安装torch,后安装fastpt)
pip install pytest
pip install wheel
pkufool's avatar
pkufool committed
37
38
```

fengzch-das's avatar
fengzch-das committed
39
40
41
42
#### 源码编译安装
- 代码下载
```shell
git clone http://developer.sourcefind.cn/codes/OpenDAS/fast_rnnt.git # 根据编译需要切换分支
pkufool's avatar
pkufool committed
43
```
fengzch-das's avatar
fengzch-das committed
44
- 提供2种源码编译方式(进入fast_rnnt目录):
pkufool's avatar
pkufool committed
45
```
fengzch-das's avatar
fengzch-das committed
46
47
1. 设置不转码编译环境变量
source /usr/local/bin/fastpt -C
pkufool's avatar
pkufool committed
48

fengzch-das's avatar
fengzch-das committed
49
50
51
2. 编译whl包并安装
python3 setup.py bdist_wheel
pip install dist/fast_rnnt* --no-deps
pkufool's avatar
pkufool committed
52

fengzch-das's avatar
fengzch-das committed
53
54
3. 源码编译安装
python3 setup.py install --no-deps
pkufool's avatar
pkufool committed
55
```
fengzch-das's avatar
fengzch-das committed
56
57
58
59
#### 注意事项
+ 若使用pip install下载安装过慢,可添加pypi清华源:-i https://pypi.tuna.tsinghua.edu.cn/simple/
+ ROCM_PATH为dtk的路径,默认为/opt/dtk
+ 在pytorch2.5.1环境下编译需要支持c++17语法,打开setup.py文件,把文件中的 -std=c++14 修改为 -std=c++17
pkufool's avatar
pkufool committed
60

fengzch-das's avatar
fengzch-das committed
61
## 验证
pkufool's avatar
pkufool committed
62
```
fengzch-das's avatar
fengzch-das committed
63
64
65
66
67
68
69
python3
Python 3.10.12 (main, May 27 2025, 17:12:29) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import fast_rnnt
>>> fast_rnnt.__version__
'1.2'
>>>
pkufool's avatar
pkufool committed
70
```
fengzch-das's avatar
fengzch-das committed
71
版本号与官方版本同步,查询该软件的版本号,例如0.3;
pkufool's avatar
pkufool committed
72

fengzch-das's avatar
fengzch-das committed
73
74
## Known Issue
-
pkufool's avatar
pkufool committed
75

fengzch-das's avatar
fengzch-das committed
76
77
78
## 参考资料
- [README_ORIGIN](README_ORIGIN.md)
- [https://github.com/princeton-vl/fast_rnnt](https://github.com/k2-fsa/fast_rnnt)