openvpi / DiffSinger

An advanced singing voice synthesis system with high fidelity, expressiveness, controllability and flexibility based on DiffSinger: Singing Voice Synthesis via Shallow Diffusion Mechanism
Apache License 2.0
2.68k stars 283 forks source link

Torch2.2 Error Variance #168

Closed usasho closed 7 months ago

usasho commented 7 months ago

Failed to run editing macro [ErrorCode:RuntimeException] Non-zero status code returned while running Reshape node. Name:'/encoder/layers.0/op/self_attn/Reshape_4' Status Message: D:\a_work\1\s\onnxruntime\core\providers\cpu\tensor\reshape_helper.h:41 onnxruntime::ReshapeHelper::ReshapeHelper gsl::narrow_cast(input_shape.Size()) == size was false. The input tensor cannot be reshaped to the requested shape. Input shape:{3,1,128}, requested shape:{5,2,64}

Microsoft.ML.OnnxRuntime.OnnxRuntimeException: [ErrorCode:RuntimeException] Non-zero status code returned while running Reshape node. Name:'/encoder/layers.0/op/self_attn/Reshape_4' Status Message: D:\a_work\1\s\onnxruntime\core\providers\cpu\tensor\reshape_helper.h:41 onnxruntime::ReshapeHelper::ReshapeHelper gsl::narrow_cast(input_shape.Size()) == size was false. The input tensor cannot be reshaped to the requested shape. Input shape:{3,1,128}, requested shape:{5,2,64}

at Microsoft.ML.OnnxRuntime.NativeApiStatus.VerifySuccess(IntPtr nativeStatus) at Microsoft.ML.OnnxRuntime.InferenceSession.RunImpl(RunOptions options, IntPtr[] inputNames, IntPtr[] inputValues, IntPtr[] outputNames, DisposableList1 cleanupList) at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection1 inputs, IReadOnlyCollection1 outputNames, RunOptions options) at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection1 inputs, IReadOnlyCollection1 outputNames) at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection1 inputs) at OpenUtau.Core.DiffSinger.DsPitch.Process(RenderPhrase phrase) in C:\projects\openutau\OpenUtau.Core\DiffSinger\DiffSingerPitch.cs:line 126 at OpenUtau.Core.DiffSinger.DiffSingerRenderer.LoadRenderedPitch(RenderPhrase phrase) in C:\projects\openutau\OpenUtau.Core\DiffSinger\DiffSingerRenderer.cs:line 304 at OpenUtau.Core.Editing.LoadRenderedPitch.Run(UProject project, UVoicePart part, List`1 selectedNotes, DocManager docManager) in C:\projects\openutau\OpenUtau.Core\Editing\NoteBatchEdits.cs:line 464 at OpenUtau.App.ViewModels.PianoRollViewModel.<.ctor>b__94_10(BatchEdit edit) in C:\projects\openutau\OpenUtau\ViewModels\PianoRollViewModel.cs:line 167

0.1.384.0

An error occurred when using Diffsinger's ONNX Variance function No error occurred when converting Torch version 1.18 to Onnx. This time I used Torch 2.2 and got an Onnx error. Have the model parameters themselves changed?

The version of Torch currently used for both SOME and SOFA is 2.2. Thank you for your improvement.

yqzhishen commented 7 months ago

Did you export your ONNX model with the right version of PyTorch (1.13)?

usasho commented 7 months ago

Yes, 1.13 can be converted correctly The latest torch 2.2 is now mainstream, and the tool for creating training data some.sofa can only be used with pytorch 2.2.Since torch itself takes up a lot of space, installing multiple versions is also a hassle.

yqzhishen commented 7 months ago

So you confirm your model is exported under PyTorch 1.13, and is used with the latest version of OpenUTAU? Please note that the ONNX exporter is only expected to work under PyTorch 1.13, and under other version it may break even if it seems to run successfully. Have you tried other projects? Does every project raise this error?

usasho commented 7 months ago

Yes, onnx exported with pytorch 1.13 can be used.pytorch2 cannot be reshaped and is exported, but cannot be used.

yqzhishen commented 7 months ago

I can now confirm that you exported the model with PyTorch 2.2, because I tried PyTorch 2.2 and reproduced your error. This is due to a bug of PyTorch itself, and I will not fix it.

Anyway, I have told you that exporting the model sucessfully does not mean the model is correct, and PyTorch 1.13 is the only version that is tested and verified. Please install PyTorch 1.13 to export the model. Only the CPU-only version is enough so it will not take much space.