You would have to use a batch size for the model and training, which fits into the memory of your device.
Too large batch sizes will try to use too much memory and will thus yield the “out of memory” issue.