5,323
edits
Line 72: | Line 72: | ||
==Optimizations== | ==Optimizations== | ||
===Reducing memory usage=== | ===Reducing GPU memory usage=== | ||
* Save loss using [https://pytorch.org/docs/stable/tensors.html#torch.Tensor.item <code>.item()</code>] which returns a standard Python number | * Save loss using [https://pytorch.org/docs/stable/tensors.html#torch.Tensor.item <code>.item()</code>] which returns a standard Python number | ||
* For non-scalar items, use <code>my_var.detach().cpu().numpy()</code> | * For non-scalar items, use <code>my_var.detach().cpu().numpy()</code> |