but my batch_size is 8 also reply this error
THCudaCheck FAIL file=d:\downloads\pytorch-master-1\torch\lib\thc\generic/THCStorage.cu line=66 error=2 : out of memory
Traceback (most recent call last):
File “F:/yzy/03Pytorch_classify/train_test.py”, line 80, in 
loss.backward()
File “D:\ProgramData\Anaconda3\lib\site-packages\torch\autograd\variable.py 1”, line 144, in backward
self._execution_engine.run_backward((self,), (gradient,), retain_variables)
File “D:\ProgramData\Anaconda3\lib\site-packages\torch\autograd\function.py”, line 90, in apply
return self._forward_cls.backward(self, *args)
File “D:\ProgramData\Anaconda3\lib\site-packages\torch\nn_functions\linear.py”, line 27, in backward
grad_weight = torch.mm(grad_output.t(), input)
File “D:\ProgramData\Anaconda3\lib\site-packages\torch\autograd\variable.py 1”, line 523, in mm
output = Variable(self.data.new(self.data.size(0), matrix.data.size(1)))
RuntimeError: cuda runtime error (2) : out of memory at d:\downloads\pytorch-master-1\torch\lib\thc\generic/THCStorage.cu:66
my code is
#超参数
num_epochs = 2
batch_size = 8
learning_rate = 0.001
cnn = CNN()
print(cnn)
cnn.cuda()
if name == ‘main’:
#误差和优化
loss_fun = nn.CrossEntropyLoss().cuda()
optimizer = torch.optim.SGD(cnn.parameters(), lr=learning_rate)
#训练模型
cnn.train()
for epoch in range(num_epochs):
    train_loss = 0
    train_acc = 0
    for i, (images, labels) in enumerate(train_loader):
        images = Variable(images).cuda()
        #print(labels)
        labels = Variable(labels).cuda()
        #print(labels)
        #前向传播 反向传播 优化
        optimizer.zero_grad()
        output = cnn(images)
        loss = loss_fun(output, labels)
        loss.backward()
        optimizer.step()