Open TJN25 opened 1 year ago
I have found that adding the test if isinstance(model, nn.DataParallel):
and assigning an object zdim_value
to use later has worked.
if isinstance(model, nn.DataParallel):
zdim_value = model.module.zdim
else:
zdim_value = model.zdim
z_mu_all = torch.zeros((data.nptcls, zdim_value), device=device, dtype=torch.half if use_amp else torch.float) #changed model.zdim for zdim_value
z_logvar_all = torch.zeros((data.nptcls, zdim_value), device=device, dtype=torch.half if use_amp else torch.float) #changed model.zdim for zdim_value
Describe the bug When running the
quicktest.py
example and adding the flag--multigpu
the errorAttributeError: 'DataParallel' object has no attribute 'zdim'
is produced.To Reproduce Running the first command from within
quicktest.py
modified with--multigpu
and possibly(?)--num-workers 2
(to resolve a previous issue).Expected behavior The script to run the whole way through and not give this error.
Additional context I have dug into it and the
train_vae.py
file (line 257 and 258) have a call formodel.zdim
. With the--multigpu flag
, the data type isDataParallel
and notTiltSeriesHetOnlyVAE
. This error can be cleared by changing this tomodel.module.zdim
but then it fails without--mulitgpu
as the data type isTiltSeriesHetOnlyVAE
.Adding the lines:
resolves the error messages, but I do not know if this retains the function of the code.