photosynthesis-team / piq

Measures and metrics for image2image tasks. PyTorch.
Apache License 2.0
1.32k stars 114 forks source link

Feasibility of computation of IW-SSIM on CUDA #310

Closed snk4tr closed 2 years ago

snk4tr commented 2 years ago

Describe the bug Computation of IW-SSIM on CPU works fine. However, an attempt to compute this metric on CUDA causes An illegal memory access error.

To Reproduce Steps to reproduce the behavior:

  1. Checkout to feature/extend_bench
  2. Run tests/results_benchmark.py with --metrics IW-SSIM
  3. See error

Expected behavior Metric can is computed both on CPU and GPU.

Screenshots telegram-cloud-photo-size-2-5330155183314942109-y

Additional context The IW-SSIM code has not been tested on GPU

denproc commented 2 years ago

Hi @snk4tr, thank you for bug report!

The reason for such error is in line 370. The tensor is created on cpu. The bug will be fixed soon.

denproc commented 2 years ago

I managed to fix it for torch >=1.5.1, <1.8.0 | >=1.10.0. Unfortunately, there are bugs in torch == 1.8.0,1.8.1,1.9.0,1.9.1 that produce the error/warning shown in the screenshots.

When using torch.simeig: 1.8.0; 1.8.1 ERROR:

image

1.9.0; 1.9.1 WARNING:

image

When using torch.linalg.eigh: 1.9.0, 1.9.1 ERROR:

image

Therefore, we should choose a solution for mention versions. I would suggest to

cc'd @snk4tr @zakajd

snk4tr commented 2 years ago

@denproc thanks for investigating this! I is really unfortunate that new versions of PyTorch have such bugs in pretty widely used functions. Are these bugs at least reported? I like the proposed approach. Please proceed with PR.

denproc commented 2 years ago

@snk4tr The issue was fixed in torch>=1.10 but I don't have the link to the issue/PR in PyTorch repo.