# RuntimeError: \[enforce fail at CPUAllocator.cpp:68\]

**URL:** <https://discuss.pytorch.org/t/runtimeerror-enforce-fail-at-cpuallocator-cpp-68/142666>\
**Category:** tensorboard\
**Created:** [January 27, 2022, 9:41am UTC](https://discuss.pytorch.org/t/runtimeerror-enforce-fail-at-cpuallocator-cpp-68/142666 "2022-01-27T09:41:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samah\_Abu\_saleem](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/samah_abu_saleem/32/43535_2.png) [@Samah\_Abu\_saleem](https://discuss.pytorch.org/u/Samah_Abu_saleem)\
**Post date:** [January 27, 2022, 9:41am UTC](https://discuss.pytorch.org/t/runtimeerror-enforce-fail-at-cpuallocator-cpp-68/142666/1 "2022-01-27T09:41:20Z")

</div>

I am new in Pytorch. I got this error when I was trying to train the GCN model on my custom dataset.

The error:

```auto
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/tmp/ipykernel_61/1753868253.py in <module>
     30 # Run for 200 epochs (range is exclusive in the upper bound)
     31 for epoch in range(1, 201):
---> 32 train()
     33 train_acc = test(train_loader)
     34 test_acc = test(test_loader)

/tmp/ipykernel_61/1753868253.py in train()
     10 for data in train_loader:
     11 print('x_shape:',data.x.shape)
---> 12 out = model(data.x.float(), data.edge_index, data.batch)
     13 loss = criterion(out, data.num_classes)
     14 loss.backward()

RuntimeError: [enforce fail at CPUAllocator.cpp:68] . DefaultCPUAllocator: can't allocate memory: you tried to allocate 8609587200 bytes. Error code 12 (Cannot allocate memory)

```

My code:

```auto
train_loader = DataLoader(trainset, batch_size=64, shuffle=True)
test_loader = DataLoader(testset, batch_size=64, shuffle=False)

# Define our GCN class as a pytorch Module
class GCN(torch.nn.Module):
    def __init__ (self, hidden_channels):
        super(GCN, self). __init__ ()
        # We inherit from pytorch geometric's GCN class, and we initialize three layers
        self.conv1 = GCNConv(data.num_features, hidden_channels)
        self.conv2 = GCNConv(hidden_channels, hidden_channels)
        self.conv3 = GCNConv(hidden_channels, hidden_channels)
        # Our final linear layer will define our output
        self.lin = Linear(hidden_channels, 8)
        
    def forward(self, x, edge_index, batch):
      # 1. Obtain node embeddings 
      x = self.conv1(x, edge_index)
      x = x.relu()
      x = self.conv2(x, edge_index)
      x = x.relu()
      x = self.conv3(x, edge_index)   
 
      # 2. Readout layer
      x = global_mean_pool(x, batch) # [batch_size, hidden_channels]
 
      # 3. Apply a final classifier
      x = F.dropout(x, p=0.5, training=self.training)
      x = self.lin(x)
      return x
    
model = GCN(hidden_channels=64)

```

---

<div class="post-metadata">

**Author:** ![InnovArul](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/innovarul/32/5282_2.png) [@InnovArul](https://discuss.pytorch.org/u/InnovArul)\
**Post date:** [January 27, 2022, 3:16pm UTC](https://discuss.pytorch.org/t/runtimeerror-enforce-fail-at-cpuallocator-cpp-68/142666/2 "2022-01-27T15:16:58Z")

</div>

> [@Samah\_Abu\_saleem](#):
>
> `DefaultCPUAllocator: can't allocate memory: you tried to allocate 8609587200 bytes.`

The error message seems clear?  
That your model is needing more memory than the GPU memory size?

---

<div class="post-metadata">

**Author:** ![lesnikow](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/l/eb8c5e/32.png) [@lesnikow](https://discuss.pytorch.org/u/lesnikow)\
**Post date:** [March 12, 2022, 6:41pm UTC](https://discuss.pytorch.org/t/runtimeerror-enforce-fail-at-cpuallocator-cpp-68/142666/3 "2022-03-12T18:41:18Z")

</div>

`DefaultCPUAllocator` is not the same as e.g. `DefaultCUDAAllocator`.
