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

pytorch 运行的时候出现了下面的错误:

loading 9423 train samples...
loading 1048 dev samples...
Traceback (most recent call last):
  File "train.py", line 170, in <module>
    main()
  File "train.py", line 166, in main
    train_net(args)
  File "train.py", line 73, in train_net
    logger=logger)
  File "train.py", line 115, in train
    pred, gold = model(padded_input, input_lengths, padded_target)
  File "/home/eric/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in __call__
    result = self.forward(*input, **kwargs)
  File "/media/data/sinovation_ventures/speechTransformer/transformer/transformer.py", line 35, in forward
    input_lengths)
  File "/home/eric/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in __call__
    result = self.forward(*input, **kwargs)
  File "/media/data/sinovation_ventures/speechTransformer/transformer/decoder.py", line 98, in forward
    slf_attn_mask = (slf_attn_mask_keypad + slf_attn_mask_subseq).gt(0)
RuntimeError: expected device cuda:0 and dtype Byte but got device cuda:0 and dtype Bool

我的torch版本是1.2

解决方法

pip install torch==1.4

参考文献

[1].fix runtime error with pytorch 1.2.0. https://github.com/jadore801120/attention-is-all-you-need-pytorch/pull/115

猜你喜欢

转载自blog.csdn.net/w5688414/article/details/105791294