This is a very basic level question meanwhile hard for me to collect examples on Web to figure this out:

  
      gist.github.com
  
  
    https://gist.github.com/monajalal/322f1e86496701d4b7b55a4d0fd80241 1
loocv_864images.ipynb
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from __future__ import print_function, division\n",
    "\n",
This file has been truncated. show original




  
  
    
    
  
  


My code above fails because I am passing all of the 863 images (1 left for test purpose as in Leave-One-Out Cross-Validation). Actually, am I correct? I got CUDA ran out of memory error so I assumed that is the reason.
How can I fix this situation by batching the data and passing it to the training? Can you please provide a starter code or so? I am quite new to PyTorch and still very baffled with all the new syntaxes.
The commented section of code that uses enumerate(dataloader), passes only 1 train example to train_model method. How can I pass like 20 at a time? What do you suggest as a number to pass? (I know it is a hyper-parameter but what is a rule-of-the-thumb formula for so?
I have two 1080Ti GPU with 12GB memory and 64GB memory on my machine.
P.S.: Same code actually works, if I only have 50 images and pass 49 of them to the train_model method while having only two classes: https://gist.github.com/monajalal/0ea50727eb57b35a6ea3a6f9ff4415f1 1