File tree Expand file tree Collapse file tree 1 file changed +2
-21
lines changed
sdks/python/apache_beam/utils Expand file tree Collapse file tree 1 file changed +2
-21
lines changed Original file line number Diff line number Diff line change @@ -117,25 +117,6 @@ def __dir__(self):
117117 return dir
118118
119119
120- def _run_with_oom_protection (func , * args , ** kwargs ):
121- try :
122- return func (* args , ** kwargs )
123- except Exception as e :
124- # Check string to avoid hard import dependency
125- if 'CUDA out of memory' in str (e ):
126- logging .warning ("Caught CUDA OOM during operation. Cleaning memory." )
127- try :
128- import gc
129- import torch
130- gc .collect ()
131- torch .cuda .empty_cache ()
132- except ImportError :
133- pass
134- except Exception as cleanup_error :
135- logging .error ("Failed to clean up CUDA memory: %s" , cleanup_error )
136- raise e
137-
138-
139120class _SingletonEntry :
140121 """Represents a single, refcounted entry in this process."""
141122 def __init__ (
@@ -145,15 +126,15 @@ def __init__(
145126 self .refcount = 0
146127 self .lock = threading .Lock ()
147128 if initialize_eagerly :
148- self .obj = _run_with_oom_protection ( constructor )
129+ self .obj = constructor ( )
149130 self .initialied = True
150131 else :
151132 self .initialied = False
152133
153134 def acquire (self ):
154135 with self .lock :
155136 if not self .initialied :
156- self .obj = _run_with_oom_protection ( self .constructor )
137+ self .obj = self .constructor ( )
157138 self .initialied = True
158139 self .refcount += 1
159140 return _SingletonProxy (self )
You can’t perform that action at this time.
0 commit comments