FakerYFX / Bert-Pytorch-Chinese-TextClassification

Pytorch Bert Finetune in Chinese Text Classification
210 stars 36 forks source link

when I run the shell,hava a CUDA error to me. it will runing on a right status if i use cpu. #2

Open WavesLi opened 5 years ago

WavesLi commented 5 years ago

python3 run_classifier_word.py --task_name NEWS --do_train --do_eval --data_dir $GLUE_DIR/ --vocab_file $BERT_BASE_DIR/vocab.txt --bert_config_file $BERT_BASE_DIR/bert_config.json --init_checkpoint $BERT_BASE_DIR/pytorch_model.bin --max_seq_length 256 --train_batch_size 24 --learning_rate 2e-5 --num_train_epochs 50.0 --output_dir ./newsAll_output/ --local_rank 3 04/16/2019 16:33:35 - INFO - main - device cuda:3 n_gpu 1 distributed training True 04/16/2019 16:33:35 - INFO - main - LOOKING AT /home/gpu0/Litao/Bert/Bert-Pytorch-Chinese-TextClassification/Corpus/train.tsv label_list.size:10

Traceback (most recent call last): File "run_classifier_word.py", line 704, in main() File "run_classifier_word.py", line 559, in main model.to(device) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 381, in to return self._apply(convert) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 187, in _apply module._apply(fn) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 187, in _apply module._apply(fn) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 187, in _apply module._apply(fn) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 193, in _apply param.data = fn(param.data) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 379, in convert return t.to(device, dtype if t.is_floating_point() else None, non_blocking) RuntimeError: CUDA error: invalid device ordinal

WavesLi commented 5 years ago

@xieyufei1993 I guess this question because my GPU is too small to run the shell.Can you tell me about you GPU's memory?

zhanlaoban commented 5 years ago

@WavesLi I guess you only have one GPU in your PC, and that the parameter local_rank is 3 is not for you. So setting local_rank default which is -1 will work.

bruce0715 commented 4 years ago

@xieyufei1993 I guess this question because my GPU is too small to run the shell.Can you tell me about you GPU's memory?

My GPU is 2080 ti 11GB, but it still out of memory...

WavesLi commented 4 years ago

You need a smaller batch.

---Original--- From: "Bruce Zhu"notifications@github.com Date: Tue, Jul 23, 2019 07:05 AM To: "xieyufei1993/Bert-Pytorch-Chinese-TextClassification"Bert-Pytorch-Chinese-TextClassification@noreply.github.com; Cc: "Mention"mention@noreply.github.com;"WavesLi"2585441465@qq.com; Subject: Re: [xieyufei1993/Bert-Pytorch-Chinese-TextClassification] when I run the shell,hava a CUDA error to me. it will runing on a right status if i use cpu. (#2)

@xieyufei1993 I guess this question because my GPU is too small to run the shell.Can you tell me about you GPU's memory?

My GPU is 2080 ti 11GB, but it still out of memory...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.