UER-py icon indicating copy to clipboard operation
UER-py copied to clipboard

RuntimeError when fine-tuning on CPU machine

Open Embedding opened this issue 3 years ago • 1 comments

Run the following command on CPU machine:

python3 finetune/run_classifier.py --pretrained_model_path models/book_review_model.bin \
                                   --vocab_path models/google_zh_vocab.txt \
                                   --config_path models/bert/base_config.json \
                                   --train_path datasets/douban_book_review/train.tsv \
                                   --dev_path datasets/douban_book_review/dev.tsv \
                                   --test_path datasets/douban_book_review/test.tsv \
                                   --epochs_num 3 --batch_size 32

RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

Embedding avatar Feb 28 '22 17:02 Embedding

我用pycharm运行也是需要修改这个地方 model.load_state_dict(torch.load(args.pretrained_model_path, map_location='cuda:0'), strict=False)

vegaviazhang avatar Mar 01 '22 11:03 vegaviazhang