# Possible bug? Linear layer does not throw error on incorrect input size when on GPU

**URL:** <https://discuss.pytorch.org/t/possible-bug-linear-layer-does-not-throw-error-on-incorrect-input-size-when-on-gpu/132432>\
**Category:** Uncategorized\
**Created:** [September 21, 2021, 12:04am UTC](https://discuss.pytorch.org/t/possible-bug-linear-layer-does-not-throw-error-on-incorrect-input-size-when-on-gpu/132432 "2021-09-21T00:04:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![KFrank](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/k/ecb155/32.png) [@KFrank](https://discuss.pytorch.org/u/KFrank)\
**Post date:** [September 21, 2021, 2:01am UTC](https://discuss.pytorch.org/t/possible-bug-linear-layer-does-not-throw-error-on-incorrect-input-size-when-on-gpu/132432/2 "2021-09-21T02:01:18Z")

</div>

Hi Ada!

> [@Ada](#):
>
> throws `RuntimeError: mat1 and mat2 shapes cannot be multiplied (1x200 and 100x1)`, as expected.
> 
> However, if I put it on the GPU:  
> …  
> it happily computes without throwing an error.

This appears to be a known bug that has recently been fixed. See  
this thread:

> [@Pytorch is allowing incorrect matrix multiplication when using cuda](https://discuss.pytorch.org/t/pytorch-is-allowing-incorrect-matrix-multiplication-when-using-cuda/130664):
>
> Hey everyone, I have a minor issue and I am not sure if it is a bug or I am simply not understanding something. But I noticed that in my project I was getting some strange results for certain configurations and error messages not popping up when expected. To boil it down, I am allowed to multiply matrices of incompatible sizes so long as it takes place on the gpu. When running the following: input = torch.randn(5, 10) network = nn.Linear(3, 3) output = network(input) ## This should fail I …

Best.

K. Frank

---

_[View the full topic](https://discuss.pytorch.org/t/possible-bug-linear-layer-does-not-throw-error-on-incorrect-input-size-when-on-gpu/132432)._
