[Solved] RuntimeError: cublas runtime error : resource allocation failed at

[root@bsyocr server-train]# tail trainall210722_6.log.txt
File “/home/server-train/pytorch_pretrained/modeling.py”, line 300, in forward
mixed_query_layer = self.query(hidden_states)
File “/usr/local/lib64/python3.6/site-packages/torch/nn/modules/module.py”, line 547, in __call__
result = self.forward(*input, **kwargs)
File “/usr/local/lib64/python3.6/site-packages/torch/nn/modules/linear.py”, line 87, in forward
return F.linear(input, self.weight, self.bias)
File “/usr/local/lib64/python3.6/site-packages/torch/nn/functional.py”, line 1371, in linear
output = input.matmul(weight.t())
RuntimeError: cublas runtime error : resource allocation failed at /pytorch/aten/src/THC/THCGeneral.cpp:216

RuntimeError: CUDA out of memory. error when running the model Checked a lot of related content, the reason is: GPU memory memory is not enough Briefly summarize the solution: change the batch_size to a smaller size

Modify the pad.size of bert from 2048 -> 1024

Read More: