What is the value of n_predictions?
When does it run out of memory? (Are you accumulating history across iterations)? Can you post a link to the rest of your code?

loss += ... will combine the current graph of loss with the subgraph for multiplcator[j] / .... That’s unavoidable if you want to backpropagate through loss. If you don’t need to compute a derivative, use:
with torch.no_grad():
  <code>

You can rewrite your expression to avoid the for-loops. I’m not sure if this will help with memory usage. It’ll likely be faster.
diff = prediction.reshape(-1, 1) - prediction  # diff[i][j] = prediction[i] - prediction[j]
denom = 1 + torch.exp(-self.gamma * diff)
losses = multiplicator / denom
losses = torch.triu(losses)  # return upper triangular part of diff (i.e. zero out `i < j`)
loss = losses.sum()