artyom-beilis / pytorch_dlprim

DLPrimitives/OpenCL out of tree backend for pytorch
http://blog.dlprimitives.org/
MIT License
227 stars 16 forks source link

Error when Running Pyannote Audio on OpenCL Backend - RuntimeError: Running sums are expected to be present #55

Open HideyoshiNakazone opened 5 months ago

HideyoshiNakazone commented 5 months ago

OS VERSION: Ubuntu 22.04 Mesa Version: 23.2.1-1ubuntu3.1~22.04.2 Python Version: 3.12.1


When running a Pyannote Pipeline with this Torch Backend the following exception is raised:

  File "$HOME/.cache/pypoetry/virtualenvs/mega-transcriptor-api-ZX9jWx3P-py3.12/lib/python3.12/site-packages/torch/nn/functional.py", line 2526, in instance_norm
    return torch.instance_norm(
           ^^^^^^^^^^^^^^^^^^^^
RuntimeError: Running sums are expected to be present

The backend is initialized and passed to the pipeline via the following code:

    torch.ops.load_library("pytorch_dlprim/build/dlprimitives/libdlprim_core.so")
    torch.ops.load_library("pytorch_dlprim/build/libpt_ocl.so")

    torch.utils.rename_privateuse1_backend('ocl')

    pipeline.to(torch.device("ocl:0"))

All PyTorch Packages where installed via the following repo: https://download.pytorch.org/whl/cpu/

Thanks for all your work, Vitor Hideyoshi

artyom-beilis commented 5 months ago

Interesting. It looks like it is implemented as batch normalization but without running mean/variance.

I need to check if I can fix it.

What are the inputs for torch.instance_norm?

HideyoshiNakazone commented 5 months ago

I will write a function that runs that function directly, because the function call was made by another package

HideyoshiNakazone commented 5 months ago

I wasn't able to replicate it, but i ran the program in debug mode and created a pickle file with the input args for the following function call.

    torch.instance_norm(
        input, weight, bias, running_mean, running_var, use_input_stats, momentum, eps, torch.backends.cudnn.enabled
    )

dump.zip

Also, when running the function directly in the debug mode the following exception was thrown:

RuntimeError: Running sums are expected to be present
artyom-beilis commented 5 months ago
torch.instance_norm(
       input, weight, bias, running_mean, running_var, use_input_stats, momentum, eps, torch.backends.cudnn.enabled
   )

Can you tell what are the parameters (shapes, scalar values etc) It is on forward or backward path?