henryhungle / NADST

Code for the paper Non-Autoregressive Dialog State Tracking (ICLR20)
MIT License
44 stars 5 forks source link

How to run CPU mode from Pytorch #2

Closed koliaok closed 4 years ago

koliaok commented 4 years ago

hello I try to run NADST train with CPU mode, but occurring error

my os: MAC

run script parameter is same your run script and I change "USE_CUDA=False" and remove model.cuda()

my error window is :

/Users/kimhyungrak/Library/Caches/pypoetry/virtualenvs/ls-KaK2QlFp-py3.7/bin/python /Users/kimhyungrak/Desktop/NADST/train.py -path=save/nadst -d=256 -h_attn=16 -bsz=32 -wu=20000 -dr=0.2 -dv=2.1 -fert_dec_N=3 -state_dec_N=3 data_version=2.1 delex_his=1 sys_act=1 dataset=multiwoz path=save/nadst patience=6 batch=32 warmup=20000 label_smoothing=1 evalp=1 reportp=100 eval_batch=16 eval_epoch=-1 test_split=test eval_metric=acc p_test=1 p_test_fertility=1 test_domain=None test_output=None out2in_atrg=0 auto_regressive=0 sep_input_embedding=1 sep_output_embedding=0 slot_gating=0 slot_lenval=1 pointer_decoder=1 no_pe_ds_emb1=0 no_pe_ds_emb2=0 fert_dec_N=3 state_dec_N=3 d_model=256 d_embed=-1 h_attn=16 drop=0.2 Reading from data2.1/nadst_train_dials.json domain_counter {'hotel': 3381, 'police': 245, 'train': 3103, 'attraction': 2717, 'restaurant': 3813, 'hospital': 287, 'taxi': 1654} multival_count 225 Reading from data2.1/nadst_dev_dials.json domain_counter {'train': 484, 'hotel': 416, 'attraction': 401, 'restaurant': 438, 'taxi': 207} multival_count 19 Reading from data2.1/nadst_test_dials.json domain_counter {'taxi': 195, 'attraction': 395, 'restaurant': 437, 'train': 494, 'hotel': 394} multival_count 0 Read 56668 pairs train Read 7374 pairs dev Read 7368 pairs test Vocab_size: 18312 Vocab_size Training 18312 Vocab_size Belief 877 Vocab_size Domain 11 Vocab_size Slot 22 Max. len of value per slot: train 9 dev 8 test 8 all 9 USE_CUDA=False /Users/kimhyungrak/Desktop/NADST/model/nadst.py:137: UserWarning: nn.init.xavier_uniform is now deprecated in favor of nn.init.xavieruniform. nn.init.xavier_uniform(p) /Users/kimhyungrak/Library/Caches/pypoetry/virtualenvs/ls-KaK2QlFp-py3.7/lib/python3.7/site-packages/torch/nn/_reduction.py:43: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead. warnings.warn(warning.format(ret)) epoch 1/200: 0% 0/1771 [00:00<?, ?it/s]Epoch:0 epoch 1/200: 0% 0/1771 [00:04<?, ?it/s] Traceback (most recent call last): File "/Users/kimhyungrak/Desktop/NADST/train.py", line 159, in run_epoch(epoch, 200, train, model, False) File "/Users/kimhyungrak/Desktop/NADST/train.py", line 45, in run_epoch losses, nb_tokens = loss_compute(out, data, is_eval) File "/Users/kimhyungrak/Desktop/NADST/model/optimizer.py", line 77, in call state_out = self.model.state_decoder.state_gen(out, data['context'], data['context_mask']) File "/Users/kimhyungrak/Library/Caches/pypoetry/virtualenvs/ls-KaK2QlFp-py3.7/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call result = self.forward(*input, **kwargs) File "/Users/kimhyungrak/Desktop/NADST/model/generators.py", line 54, in forward p_context_ptr = torch.zeros(p_vocab.size()).cuda() File "/Users/kimhyungrak/Library/Caches/pypoetry/virtualenvs/ls-KaK2QlFp-py3.7/lib/python3.7/site-packages/torch/cuda/init.py", line 149, in _lazy_init _check_driver() File "/Users/kimhyungrak/Library/Caches/pypoetry/virtualenvs/ls-KaK2QlFp-py3.7/lib/python3.7/site-packages/torch/cuda/init.py", line 47, in _check_driver raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled

Process finished with exit code 1

plz feedback

Thank you

henryhungle commented 4 years ago

@koliaok thanks for pointing out. There might be some parts in the codes where cuda() is inserted manually and you need to remove them to run in CPU mode. From the error message, you can try to remove cuda() in https://github.com/henryhungle/NADST/blob/afdc1d1f7ecb855b03933e441c0b2fcefbc28feb/model/generators.py#L54

koliaok commented 4 years ago

thank you for your feedback

I apply your teaching then, run training of CPU mode without error message