Open ntedgi opened 4 years ago
torch.no_grad() impacts the autograd engine and deactivate it. It will reduce memory usage and speed up computations but you won’t be able to backprop (which you don’t want in an eval script).
https://github.com/kamalkraj/BERT-NER/pull/71 torch.no_grad() crush on tokens larger the 512 this pr will close it
its not an floating point issue between devices and then only the certainty changes on GPU i get (4/18) on CPU (16/18)
in order to hard code GPU and then CPU i follow this commit https://github.com/kamalkraj/BERT-NER/commit/6286a475b3f85ad595f37b27d1e0d2a31e6edf70 and change this 2 lines
line 20:
valid_output = torch.zeros(batch_size,max_len,feat_dim,dtype=torch.float32,device='cuda' if torch.cuda.is_available() else 'cpu')
... Line 38:self.device = "cuda" if torch.cuda.is_available() else "cpu"
one time to 'cpu' and in the other to 'cuda'
tested on: Ubuntu 18.04 NVIDIA-SMI 435.21 Driver Version: 435.21 CUDA Version: 10.1
GeForce RTX 2070
Python 3.6 pytorch-transformers==1.2.0 torch==1.2.0
example : 18 posts