Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Training ORGAN on cuda error #91

Open
Binbose opened this issue Dec 26, 2020 · 0 comments
Open

Training ORGAN on cuda error #91

Binbose opened this issue Dec 26, 2020 · 0 comments

Comments

@Binbose
Copy link

Binbose commented Dec 26, 2020

Hey,

when I train ORGAN via
python scripts/run.py --model organ --train_path ./my_organ/data/hce_smiles.smi --checkpoint_dir ./my_orgapt --device cuda:0 --metrics ./my_organ/metrics
it throws the error

Traceback (most recent call last):
  File "scripts/run.py", line 219, in <module>
    main(config)
  File "scripts/run.py", line 199, in main
    train_model(config, model, train_path, test_path)
  File "scripts/run.py", line 127, in train_model
    trainer_script.main(model, trainer_config)
  File "/home/luca/Projects/benchmark_level_up/local/moses/scripts/train.py", line 62, in main
    trainer.fit(model, train_data, val_data)
  File "/home/luca/anaconda3/envs/moses/lib/python3.6/site-packages/molsets-1.0-py3.6.egg/moses/organ/trainer.py", line 370, in fit
    gen_val_loader, logger)
  File "/home/luca/anaconda3/envs/moses/lib/python3.6/site-packages/molsets-1.0-py3.6.egg/moses/organ/trainer.py", line 104, in _pretrain_generator
    criterion, optimizer)
  File "/home/luca/anaconda3/envs/moses/lib/python3.6/site-packages/molsets-1.0-py3.6.egg/moses/organ/trainer.py", line 70, in _pretrain_generator_epoch
    outputs, _, _ = model.generator_forward(prevs, lens)
  File "/home/luca/anaconda3/envs/moses/lib/python3.6/site-packages/molsets-1.0-py3.6.egg/moses/organ/model.py", line 94, in generator_forward
    return self.generator(*args, **kwargs)
  File "/home/luca/anaconda3/envs/moses/lib/python3.6/site-packages/torch-1.7.1-py3.6-linux-x86_64.egg/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/luca/anaconda3/envs/moses/lib/python3.6/site-packages/molsets-1.0-py3.6.egg/moses/organ/model.py", line 23, in forward
    x = pack_padded_sequence(x, lengths, batch_first=True)
  File "/home/luca/anaconda3/envs/moses/lib/python3.6/site-packages/torch-1.7.1-py3.6-linux-x86_64.egg/torch/nn/utils/rnn.py", line 244, in pack_padded_sequence
    _VF._pack_padded_sequence(input, lengths, batch_first)
RuntimeError: 'lengths' argument should be a 1D CPU int64 tensor, but got 1D cuda:0 Long tensor

Seems like changing line 23 in moses/organ/model.py from
x = pack_padded_sequence(x, lengths.cpu(), batch_first=True)
to
x = pack_padded_sequence(x, lengths.cpu(), batch_first=True)
fixes the problem though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant