开发者
资源
鲲鹏Linux环境安装wenet参考
鲲鹏Linux环境安装wenet参考
发表于2023/06/06
2584

注:基于openEuler 20.03 LTS SP3系统(联网环境)。

1、安装conda

参考 鲲鹏Linux环境安装conda参考

2、安装python3和依赖

dnf -y install python3 python3-devel

3、获取wenet源码

git clone https://github.com/wenet-e2e/wenet.git

4、进入wenet源码路径

cd wenet/

5、创建conda环境

/root/miniconda3/bin/conda create -n wenet python=3.7

cke_39547.png

/root/miniconda3/bin/activate wenet

cke_41883.png

pip3 install -r requirements.txt --use-feature=2020-resolver

cke_47289.png

cke_45749.png

6、编译libtorch

1)进入libtorch路径

cd runtime/libtorch

2)安装pytorch

/root/miniconda3/bin/conda install pytorch cpuonly -c pytorch

cke_88594.png

3)创建build编译路径并进入执行cmake编译

mkdir build

cd build/

cmake ..

cke_133944.png

cke_139905.png

4)重命名libtorch-src路径下的lib文件夹(默认获取的libtorch中的so均为x86_64架构,无法在鲲鹏aarch64架构下使用

cd ../fc_base/libtorch-src

mv lib lib-bak

cke_338511.png

5)创建新的lib文件夹并将aarch64的so拷贝进去

mkdir lib

cp -r /usr/local/lib64/python3.7/site-packages/torch/lib/* lib/

cke_340772.png

6)拷贝libtorch_cpu.so依赖的so库文件到lib路径

cp -r /usr/local/lib64/python3.7/site-packages/torch.libs/* lib/

cke_405861.png

7)拷贝重命名的lib-bak文件夹下的libkineto.a到lib路径下

cp lib-bak/libkineto.a lib/

cke_410023.png

8)执行cmake编译

cd ../../build/

cmake --build .

cke_10038.png

cke_13388.png

FAQ:

1、执行cmake --build .报错“No rule to make target '../fc_base/libtorch-src/lib/libkineto.a', needed by 'api/libwenet_api.so'.  Stop.”,具体报错如下

gmake[2]: *** No rule to make target '../fc_base/libtorch-src/lib/libkineto.a', needed by 'api/libwenet_api.so'.  Stop. 

gmake[2]: Leaving directory '/root/wenet/runtime/libtorch/build' 

gmake[1]: *** [CMakeFiles/Makefile2:2317: api/CMakeFiles/wenet_api.dir/all] Error 2 

gmake[1]: Leaving directory '/root/wenet/runtime/libtorch/build' 

gmake: *** [Makefile:152: all] Error 2 

cke_378173.png

解决方法:

将重命名的lib-bak文件夹下的libkineto.a到lib路径下

cp ../fc_base/libtorch-src/lib-bak/libkineto.a ../fc_base/libtorch-src/lib/

2、执行cmake --build .报错“warning: libgomp-d22c30c5.so.1.0.0, needed by /root/wenet/runtime/libtorch/fc_base/libtorch-src/lib/libtorch_cpu.so, not found”等错误,具体报错如下:

[ 85%] Linking CXX executable label_checker_main 

/usr/bin/ld: warning: libgomp-d22c30c5.so.1.0.0, needed by /root/wenet/runtime/libtorch/fc_base/libtorch-src/lib/libtorch_cpu.so, not found (try using -rpath or -rpath-link) 

/usr/bin/ld: warning: libarm_compute-873be09e.so, needed by /root/wenet/runtime/libtorch/fc_base/libtorch-src/lib/libtorch_cpu.so, not found (try using -rpath or -rpath-link) 

/usr/bin/ld: warning: libarm_compute_graph-ab857ce5.so, needed by /root/wenet/runtime/libtorch/fc_base/libtorch-src/lib/libtorch_cpu.so, not found (try using -rpath or -rpath-link) 

/usr/bin/ld: warning: libarm_compute_core-0793f69d.so, needed by /root/wenet/runtime/libtorch/fc_base/libtorch-src/lib/libtorch_cpu.so, not found (try using -rpath or -rpath-link) 

cke_387732.png

解决方法:

 拷贝libtorch_cpu.so依赖的so库文件到lib路径

cp -r /usr/local/lib64/python3.7/site-packages/torch.libs/* ../fc_base/libtorch-src/lib/

参考:

1、https://wenet.org.cn/wenet/install.html#install-prebuilt-python-package

2、https://pytorch.org/get-started/locally/

收藏举报
Level 1
0
帖子
0
粉丝
0
获赞