Are you able to run the forward pass using the current input_batch?
If I’m not mistaken, the onnx.export method would trace the model, so needs to pass the input to it and execute a forward pass to trace all operations.
If it’s working before calling the export operation, could you try to export this model in a new script with an empty GPU, as your script might already be using some memory.