ResourceExhaustedError when building Sequential model
As described in the error message, the problem is that your model needs more memory than your GPU has. Note that OOM stands for &quot;out of memory&quot;.
The specific layer that is demanding too much memory is Dense(154457, activation='relu'). Nevertheless, the last layer is even bigger.
You should think if you really need an output of dimensionality 154457. If you really need it, you maybe should go for approaches that are specifically designed for that scenario, like adaptive softmax.
Another option is to use a GPU with more memory that can fit this model.