The initial error is raised, because your script is trying to allocate ~34GB on the GPU, while your device has only 4GB.
The second error might be raised, if you are reshaping some activations in a wrong way or if the model setup is wrong (e.g your inputs are larger or smaller than the expected shapes).
If you get stuck solving the second issue, please post a minimal executable code snippet, which would reproduce this issue.