Assuming you are using this method from torchsummary 29 you could call:
result, params_info = summary_string(
        model, input_size, batch_size, device, dtypes)

and save the result into a file instead of printing it out.