Skip to content

Commit 0e8456e

Browse files
committed
Remove oom protection
1 parent a5ee30d commit 0e8456e

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

sdks/python/apache_beam/utils/multi_process_shared.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff 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-
139120
class _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)

0 commit comments

Comments
 (0)