tensorly / tensorly

TensorLy: Tensor Learning in Python.
http://tensorly.org
Other
1.51k stars 281 forks source link

Error encountered when using tensorly.decomposition.parafac with high rank and GPU #507

Closed fufeisi closed 11 months ago

fufeisi commented 11 months ago

Describe the bug

I encountered an error while using the tensorly.decomposition.parafac function in my code. The issue arises when the rank is set to a value larger than one of the dimensions of the tensor and the code is executed on a GPU.

Steps or Code to Reproduce

import torch, tensorly
tensorly.set_backend('pytorch')
for device in ['cpu', 'cuda']:
    x = torch.rand([100, 100, 3], device=device)
    y = tensorly.decomposition.parafac(x, 4)
    print(device, x)

Expected behavior

Actual result

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument tensors in method wrapper_cat)

Versions

Linux-3.10.0-1160.90.1.el7.x86_64-x86_64-with-glibc2.17 Python 3.10.8 (main, Nov 24 2022, 14:13:03) [GCC 11.2.0] NumPy 1.23.5 SciPy 1.9.3 TensorLy 0.8.0

If you are using another backend than NumPy, please also give us the version for that backend. tensorly.set_backend('pytorch')

JeanKossaifi commented 11 months ago

Thanks for sharing a snippet to reproduce the issue @fufeisi -- this issue was fixed in #504 The issue should be resolved if you switch to the latest version on the main branch.

pvtien96 commented 7 months ago

I encountered the same issue with version 0.8.0 but noticed that it has been resolved in version 0.8.1.