Skip to content

Commit

Permalink
Add free_memory hook for pytorch
Browse files Browse the repository at this point in the history
  • Loading branch information
zeddo123 committed Jan 24, 2024
1 parent 8d77aca commit fcc1fce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Empty file added octopipes/hooks/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions octopipes/hooks/pytorch_hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import gc

import torch


def free_memory(wf_iter):
del wf_iter
torch.cuda.empty_cache()
gc.collect()

3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
'cmap'
],
extras_require={
'opencv': ['opencv-python']
'opencv': ['opencv-python'],
'pytorch': ['torch', 'torchvision']
},
classifiers=[
'Programming Language :: Python :: 3.11',
Expand Down

0 comments on commit fcc1fce

Please sign in to comment.