Controller Emulator: train chained pytorch models

I am trying to train a controller network on a pretrained emulator network
(controller → emulator → output). The process is similar to How to train only one model in multi models?, however, i do not want to update the emulator during backpropagation. (But i do need the gradients through the emulator to train the controller)

Since the emulator contains an lstm I cannot train the controller with emulator.eval() because of the following error: cudnn RNN backward can only be called in training mode

What can I do about that? Is the network altered if its parameters are not specified in optim.Adam(…)?

1 Like

You could disable cuDNN globally via torch.backends.cudnn.enabled = False or only for the RNN module raising this error via the context manager:

with torch.backends.cudnn.flags(enabled=False):
1 Like