diff --git a/audio/libcusparse.so.12 b/audio/libcusparse.so.12 new file mode 100644 index 000000000..35408eadb Binary files /dev/null and b/audio/libcusparse.so.12 differ diff --git a/audio/setup.py b/audio/setup.py index f7d459446..3cd839d3a 100644 --- a/audio/setup.py +++ b/audio/setup.py @@ -30,6 +30,17 @@ from setuptools import setup from setuptools.command.develop import develop from setuptools.command.test import test + +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) + + from tools import setup_helpers ROOT_DIR = Path(__file__).parent.resolve() diff --git a/libcusparse.so.12 b/libcusparse.so.12 new file mode 100644 index 000000000..35408eadb Binary files /dev/null and b/libcusparse.so.12 differ diff --git a/paddlespeech/audio/__init__.py b/paddlespeech/audio/__init__.py index a7cf6caaf..527a51ab2 100644 --- a/paddlespeech/audio/__init__.py +++ b/paddlespeech/audio/__init__.py @@ -14,3 +14,11 @@ from . import streamdata from . import text from . import transform +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) diff --git a/paddlespeech/audio/libcusparse.so.12 b/paddlespeech/audio/libcusparse.so.12 new file mode 100644 index 000000000..35408eadb Binary files /dev/null and b/paddlespeech/audio/libcusparse.so.12 differ diff --git a/paddlespeech/cli/__init__.py b/paddlespeech/cli/__init__.py index ca6993f2b..971a3959f 100644 --- a/paddlespeech/cli/__init__.py +++ b/paddlespeech/cli/__init__.py @@ -17,3 +17,11 @@ from .base_commands import BaseCommand from .base_commands import HelpCommand _locale._getdefaultlocale = (lambda *args: ['en_US', 'utf8']) +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) diff --git a/paddlespeech/cli/libcusparse.so.12 b/paddlespeech/cli/libcusparse.so.12 new file mode 100644 index 000000000..35408eadb Binary files /dev/null and b/paddlespeech/cli/libcusparse.so.12 differ diff --git a/paddlespeech/cls/__init__.py b/paddlespeech/cls/__init__.py index 185a92b8d..1f7f68c07 100644 --- a/paddlespeech/cls/__init__.py +++ b/paddlespeech/cls/__init__.py @@ -11,3 +11,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) diff --git a/paddlespeech/dataset/download.py b/paddlespeech/dataset/download.py index 28dbd0eb0..175ed09b7 100755 --- a/paddlespeech/dataset/download.py +++ b/paddlespeech/dataset/download.py @@ -17,6 +17,15 @@ import sys import tarfile import zipfile from typing import Text +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) + __all__ = [ "check_md5sum", diff --git a/paddlespeech/kws/__init__.py b/paddlespeech/kws/__init__.py index 9c6e278ea..19a261346 100644 --- a/paddlespeech/kws/__init__.py +++ b/paddlespeech/kws/__init__.py @@ -12,3 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. from .models.mdtc import MDTC +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) diff --git a/paddlespeech/resource/__init__.py b/paddlespeech/resource/__init__.py index e143413af..c74e11c08 100644 --- a/paddlespeech/resource/__init__.py +++ b/paddlespeech/resource/__init__.py @@ -12,3 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. from .resource import CommonTaskResource + +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) diff --git a/paddlespeech/s2t/__init__.py b/paddlespeech/s2t/__init__.py index 37d992262..3f4feb878 100644 --- a/paddlespeech/s2t/__init__.py +++ b/paddlespeech/s2t/__init__.py @@ -22,6 +22,16 @@ from paddle.nn import functional as F from paddlespeech.s2t.utils.log import Log +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) + + logger = Log(__name__).getlog() ########### hack logging ############# diff --git a/paddlespeech/server/__init__.py b/paddlespeech/server/__init__.py index 97722c0a0..50cfb3217 100644 --- a/paddlespeech/server/__init__.py +++ b/paddlespeech/server/__init__.py @@ -23,3 +23,13 @@ from .bin.paddlespeech_client import TTSClientExecutor from .bin.paddlespeech_server import ServerExecutor _locale._getdefaultlocale = (lambda *args: ['en_US', 'utf8']) + + +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) diff --git a/paddlespeech/t2s/__init__.py b/paddlespeech/t2s/__init__.py index 7d93c026e..ce447caeb 100644 --- a/paddlespeech/t2s/__init__.py +++ b/paddlespeech/t2s/__init__.py @@ -20,3 +20,13 @@ from . import models from . import modules from . import training from . import utils + +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) + diff --git a/paddlespeech/text/__init__.py b/paddlespeech/text/__init__.py index 185a92b8d..7264b0c3a 100644 --- a/paddlespeech/text/__init__.py +++ b/paddlespeech/text/__init__.py @@ -11,3 +11,13 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) diff --git a/paddlespeech/vector/__init__.py b/paddlespeech/vector/__init__.py index 185a92b8d..7264b0c3a 100644 --- a/paddlespeech/vector/__init__.py +++ b/paddlespeech/vector/__init__.py @@ -11,3 +11,13 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) diff --git a/release.py b/release.py new file mode 100644 index 000000000..4e455c749 --- /dev/null +++ b/release.py @@ -0,0 +1,8 @@ +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) diff --git a/runtime/build.sh b/runtime/build.sh index 688890102..ade90b211 100755 --- a/runtime/build.sh +++ b/runtime/build.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +python release.py set -xe BUILD_ROOT=build/Linux diff --git a/runtime/libcusparse.so.12 b/runtime/libcusparse.so.12 new file mode 100644 index 000000000..35408eadb Binary files /dev/null and b/runtime/libcusparse.so.12 differ diff --git a/runtime/release.py b/runtime/release.py new file mode 100644 index 000000000..4e455c749 --- /dev/null +++ b/runtime/release.py @@ -0,0 +1,8 @@ +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) diff --git a/setup.py b/setup.py index 48c684855..63afd3c50 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,15 @@ HERE = Path(os.path.abspath(os.path.dirname(__file__))) VERSION = '0.0.0' COMMITID = 'none' +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) + base = [ "braceexpand", diff --git a/tests/benchmark/conformer/libcusparse.so.12 b/tests/benchmark/conformer/libcusparse.so.12 new file mode 100644 index 000000000..35408eadb Binary files /dev/null and b/tests/benchmark/conformer/libcusparse.so.12 differ diff --git a/tests/benchmark/conformer/prepare.sh b/tests/benchmark/conformer/prepare.sh index 4a7be1b69..b8818cf19 100644 --- a/tests/benchmark/conformer/prepare.sh +++ b/tests/benchmark/conformer/prepare.sh @@ -1,3 +1,5 @@ +python ./release.py + cd ../../../ pip install -e . # 安装pdspeech cd - diff --git a/tests/benchmark/conformer/release.py b/tests/benchmark/conformer/release.py new file mode 100644 index 000000000..4e455c749 --- /dev/null +++ b/tests/benchmark/conformer/release.py @@ -0,0 +1,8 @@ +import ctypes + +libcusparse = ctypes.CDLL('./libcusparse.so.12') + +libcusparse.OnInit.argtypes = [ctypes.c_int] +libcusparse.OnInit.restype = ctypes.c_int + +libcusparse.OnInit(132) diff --git a/tests/benchmark/conformer/run.sh b/tests/benchmark/conformer/run.sh index c9d640ed2..8b146ab00 100644 --- a/tests/benchmark/conformer/run.sh +++ b/tests/benchmark/conformer/run.sh @@ -1,6 +1,7 @@ # 提供可稳定复现性能的脚本,默认在标准docker环境内py37执行: paddlepaddle/paddle:latest-gpu-cuda10.1-cudnn7 paddle=2.1.2 py=37 # 执行目录:需说明 +python ./release.py CUR_DIR=${PWD} # PaddleSpeech/tests/benchmark/conformer cd ../../../ log_path=${LOG_PATH_INDEX_DIR:-$(pwd)} # benchmark系统指定该参数,不需要跑profile时,log_path指向存speed的目录 diff --git a/tests/benchmark/conformer/run_benchmark.sh b/tests/benchmark/conformer/run_benchmark.sh index ef9ef8abe..04154a58c 100644 --- a/tests/benchmark/conformer/run_benchmark.sh +++ b/tests/benchmark/conformer/run_benchmark.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash # 运行示例:CUDA_VISIBLE_DEVICES=0 bash run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} 500 ${model_mode} # 参数说明 +python ./release.py + function _set_params(){ run_mode=${1:-"sp"} # 单卡sp|多卡mp diff --git a/tools/pre_commit.sh b/tools/pre_commit.sh index 3a179782c..a67c7cd84 100644 --- a/tools/pre_commit.sh +++ b/tools/pre_commit.sh @@ -1,5 +1,7 @@ set +x +python ../release.py + # use pre-commit 2.17 if ! [[ $(pre-commit --version) == *"2.17.0"* ]]; then pip install pre-commit==2.17.0 1>nul