From 0b9a977b8816f99cdb07dfa93cac149f5414d917 Mon Sep 17 00:00:00 2001 From: SATOH Kiyoshi Date: Thu, 15 Dec 2022 18:49:56 +0900 Subject: [PATCH 1/4] =?UTF-8?q?pipenv=E3=81=AE=E3=82=A4=E3=83=B3=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=83=BC=E3=83=AB=E7=94=A8=E3=83=90=E3=83=83=E3=83=81?= =?UTF-8?q?=E3=82=92=E6=BA=96=E5=82=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/install_pipenv.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 python/install_pipenv.ps1 diff --git a/python/install_pipenv.ps1 b/python/install_pipenv.ps1 new file mode 100644 index 0000000..7b2f0d2 --- /dev/null +++ b/python/install_pipenv.ps1 @@ -0,0 +1,10 @@ +pip install --upgrade pip +pip install pipenv +$pythonUserPath = python -m site --user-site +$pythonUserPath = $pythonUserPath.Replace('site-packages', 'Scripts') +$ENV:Path += ";" + $pythonUserPath +$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User") +$userPath += ";" + $pythonUserPath +[System.Environment]::SetEnvironmentVariable("Path", $userPath, "User") +$ENV:PIPENV_VENV_IN_PROJECT = '.venv' +[System.Environment]::SetEnvironmentVariable("PIPENV_VENV_IN_PROJECT", ".venv", "User") From d5f1eca8c7b838a0e2b7139c2618e8a39fc527b9 Mon Sep 17 00:00:00 2001 From: SATOH Kiyoshi Date: Thu, 15 Dec 2022 18:50:57 +0900 Subject: [PATCH 2/4] =?UTF-8?q?makeexe=E3=82=92ps1=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=81=97=E3=81=A6output=5Faudio=5Fdevice=5Flist.py?= =?UTF-8?q?=E3=82=82exe=E5=8C=96=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/{makeexe.bat => makeexe.ps1} | 1 + 1 file changed, 1 insertion(+) rename python/{makeexe.bat => makeexe.ps1} (82%) diff --git a/python/makeexe.bat b/python/makeexe.ps1 similarity index 82% rename from python/makeexe.bat rename to python/makeexe.ps1 index cfae7ed..d823b71 100644 --- a/python/makeexe.bat +++ b/python/makeexe.ps1 @@ -1 +1,2 @@ pipenv run pyinstaller mmvc_client.py --add-binary "./.venv/Lib/site-packages/onnxruntime/capi/onnxruntime_providers_shared.dll;./onnxruntime/capi/" --add-binary "./.venv/Lib/site-packages/onnxruntime/capi/DirectML.dll;./onnxruntime/capi/" --collect-data librosa --onedir --clean -y +pipenv run pyinstaller output_audio_device_list.py --onefile From 07dd43715cc550e3ef7e7144558ad095d3f44e3c Mon Sep 17 00:00:00 2001 From: SATOH Kiyoshi Date: Thu, 15 Dec 2022 18:51:18 +0900 Subject: [PATCH 3/4] =?UTF-8?q?pyinstaller=E3=82=82pipenv=E7=92=B0?= =?UTF-8?q?=E5=A2=83=E3=81=AB=E5=85=A5=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/Pipfile | 1 + 1 file changed, 1 insertion(+) diff --git a/python/Pipfile b/python/Pipfile index 4a1fdfd..dcfd9d3 100644 --- a/python/Pipfile +++ b/python/Pipfile @@ -16,6 +16,7 @@ scikit-learn = "==1.0.2" sounddevice = "==0.4.4" SoundFile = "==0.10.3.post1" onnxruntime-directml = "1.13.1" +pyinstaller = "*" [dev-packages] From 9041c62f3bbcd2e9347e9e93550a5ceb95787cca Mon Sep 17 00:00:00 2001 From: SATOH Kiyoshi Date: Thu, 15 Dec 2022 18:53:58 +0900 Subject: [PATCH 4/4] =?UTF-8?q?onnx=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=81=AEExecutionProvider=E6=AF=8E=E3=81=AE=E5=AE=9F=E8=A1=8C?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E6=80=A7=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=81=A8=E9=80=9F=E5=BA=A6=E3=82=92=E8=A6=8B=E3=82=8B=E3=81=9F?= =?UTF-8?q?=E3=82=81=E3=81=AE=E3=83=84=E3=83=BC=E3=83=AB=E3=82=92=E6=BA=96?= =?UTF-8?q?=E5=82=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/onnx_bench.py | 78 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 python/onnx_bench.py diff --git a/python/onnx_bench.py b/python/onnx_bench.py new file mode 100644 index 0000000..d4c271d --- /dev/null +++ b/python/onnx_bench.py @@ -0,0 +1,78 @@ +import argparse +import time +import onnxruntime as ort +import torch + + +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--input_onnx", required=True) + return parser.parse_args() + + +def inspect_onnx(session): + print("inputs") + for i in session.get_inputs(): + print("name:{}\tshape:{}\tdtype:{}".format(i.name, i.shape, i.type)) + print("outputs") + for i in session.get_outputs(): + print("name:{}\tshape:{}\tdtype:{}".format(i.name, i.shape, i.type)) + + +def benchmark(session): + dummy_specs = torch.rand(1, 257, 60) + dummy_lengths = torch.LongTensor([60]) + dummy_sid_src = torch.LongTensor([0]) + dummy_sid_tgt = torch.LongTensor([1]) + + use_time_list = [] + for i in range(30): + start = time.time() + output = session.run( + ["audio"], + { + "specs": dummy_specs.numpy(), + "lengths": dummy_lengths.numpy(), + "sid_src": dummy_sid_src.numpy(), + "sid_tgt": dummy_sid_tgt.numpy() + } + ) + use_time = time.time() - start + use_time_list.append(use_time) + #print("use time:{}".format(use_time)) + use_time_list = use_time_list[5:] + mean_use_time = sum(use_time_list) / len(use_time_list) + print(f"mean_use_time:{mean_use_time}") + + +def main(args): + ort_session_cpu = ort.InferenceSession( + args.input_onnx, + providers=["CPUExecutionProvider"]) + + ort_session_cuda = ort.InferenceSession( + args.input_onnx, + providers=["CUDAExecutionProvider"]) + + # DirectMLで動かすための設定 + ort_options = ort.SessionOptions() + ort_options.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL + ort_options.enable_mem_pattern = False + ort_session_dml = ort.InferenceSession( + args.input_onnx, + sess_options=ort_options, + providers=["DmlExecutionProvider"]) + + print("vits onnx benchmark") + inspect_onnx(ort_session_cpu) + print("ONNX CPU") + benchmark(ort_session_cpu) + print("ONNX CUDA") + benchmark(ort_session_cuda) + print("ONNX DirectML") + benchmark(ort_session_dml) + +if __name__ == '__main__': + args = get_args() + print(args) + main(args)