I have the following code:
try:
# faster, but requires more memory
G = self.sparse.to_dense().t() @ self.sparse.to_dense()
except torch.cuda.OutOfMemoryError:
# slower, but requires less memory
G = torch.sparse.mm(self.sparse.t(), self.sparse)
My pylance seems to think that torch.cuda.OutOfMemoryError
is not a valid error class. (See image.)
However, when I run the code, the torch.sparse.mm
runs, showing that the exception was detected.
Why does pylance think that it's invalid when it clearly works?
The reason for this issue is that torch.cuda.OutOfMemoryError
does not extend Python's Exception
class. This issue has been fixed by PyTorch now. 109961