zjpbinary / CSCBLI

Code for the ACL2021 paper "Combining Static Word Embedding and Contextual Representations for Bilingual Lexicon Induction"
14 stars 1 forks source link

RuntimeError: CUDA out of memory. #1

Closed Qiuyu-Ding closed 1 year ago

Qiuyu-Ding commented 2 years ago

As mentioned, i'm trying to test the unsuperised method, but when i run the test.sh: src=ar tgt=en model_path=../checkpoints/$src-$tgt-add_orign_nw.pkl_last CUDA_VISIBLE_DEVICES=0,1 python test.py --model_path $model_path \ --dict_path ../$src-$tgt.5000-6500.txt --mode v2 \ --src_lang $src --tgt_lang $tgt \ --reload_src_ctx $path1 \ --reload_tgt_ctx $path2 --lambda_w1 0.11 it always tell me that "RuntimeError: CUDA out of memory. Tried to allocate 2.82 GiB (GPU 0; 31.75 GiB total capacity; 28.74 GiB already allocated; 1.84 GiB free; 28.75 GiB reserved in total by PyTorch)", is it right? and can you give some advices? Thanks!

zjpbinary commented 2 years ago

Thanks for your question. Sorry to hear that you are not able to run the code. There may be various reasons for this:

  1. Maybe your vocab size is so large that torch.matmul() takes up too much memory. You may need to calculate it in batches instead of all at once.
  2. Have you used all data required during training and testing?(aligned source/target static embedding,aligned source/target context embedding, source/target context embedding)
Qiuyu-Ding commented 2 years ago

Thanks for your question. Sorry to hear that you are not able to run the code. There may be various reasons for this:

  1. Maybe your vocab size is so large that torch.matmul() takes up too much memory. You may need to calculate it in batches instead of all at once.
  2. Have you used all data required during training and testing?(aligned source/target static embedding,aligned source/target context embedding, source/target context embedding)

Thank you for your patient reply! Yes, you are right, the data i used for test maybe wrong, which lead to this error. Thank you so much~