DrugEx icon indicating copy to clipboard operation
DrugEx copied to clipboard

RuntimeError: expected device cuda:0 and dtype Byte but got device cuda:0 and dtype Bool

Open Auroraywood opened this issue 5 years ago • 4 comments

Hi!

An error occurs when I run pretrainer.py. Can you give me some advice? Thanks a lot!

Issue summary

prior.fit(zinc, out=netP_path)
/tmp/pip-req-build-58y_cjjl/aten/src/ATen/native/IndexingUtils.h:20: UserWarning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead.
Traceback (most recent call last):

  File "<ipython-input-17-9e97d71a0301>", line 1, in <module>
    prior.fit(zinc, out=netP_path)

  File "/home/tensorflow/DrugEx/model.py", line 422, in fit
    seqs = self.sample(1000)

  File "/home/tensorflow/DrugEx/model.py", line 388, in sample
    is_end = torch.ge(is_end + end_token, 1)

RuntimeError: expected device cuda:0 and dtype Byte but got device cuda:0 and dtype Bool

Auroraywood avatar Nov 04 '19 07:11 Auroraywood

I checked this part of code in my own machine (PyTorch = 1.0 or 1.3 stable), but I did not find such a bug. Could you tell me the version of PyTorch?

XuhanLiu avatar Nov 04 '19 11:11 XuhanLiu

Thank you very much! The version of my pytorch is higher and I have alreadly figure the problem out! But now, I have met another error, when I train prior model on the data zinc_corpus.txt, it occurs keyerror when encode, so I modify voc = util.Voc("data/voc.txt") to voc = util.Voc("data/zinc_voc.txt"), then keyerror in encode disappeared, but now decode occurs keyerror again, this time I am confused.

Traceback (most recent call last):
  File "pretrainer.py", line 60, in <module>
    main()
  File "pretrainer.py", line 27, in main
    prior.fit(zinc, out=netP_path)
  File "/home/tensorflow/DrugEx/model.py", line 428, in fit
    smiles, valids = util.check_smiles(seqs, self.voc)
  File "/home/tensorflow/DrugEx/util.py", line 232, in check_smiles
    smile = voc.decode(seq)
  File "/home/tensorflow/DrugEx/util.py", line 94, in decode
    chars.append(self.ix2tk[i])
KeyError: 0

Auroraywood avatar Nov 05 '19 05:11 Auroraywood

Thanks for reminding me this bug. It is caused by the duplication of 'EOS' in vocabulary defined in the file of 'voc.txt'. I have modified the 'util.py' and removed the 'EOS' defined in token sequences. If you do not want to regenerate the corpus, you can simply remove 'EOS' in the file of 'voc.txt'

XuhanLiu avatar Nov 07 '19 15:11 XuhanLiu

Thank you very much.

Auroraywood avatar Nov 08 '19 01:11 Auroraywood