(Cannot allocate memory)

Means I have not enough RAM left… (I still have enough storage 3.6 Gb)
My RAM is decreasing during training from 28141 to 5000 and lower
# at the start:
 free -m
              total        used        free      shared  buff/cache   available
Mem:          31981        1862       28141         668        1977       29026
Swap:           976           0         976

@ptrblck I included now:
torch.from_numpy(rewards["final_rewards"]).float()

Thus the memory error remains…
How can I force pytorch to not use too much memory?