MCPcopy Create free account
hub / github.com/AMAP-ML/EMF / empty_device_cache

Method empty_device_cache

trl/trl/core.py:96–110  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

94 @classmethod
95 @contextmanager
96 def empty_device_cache(cls):
97 yield
98 if cls.optimize_device_cache:
99 if is_torch_xpu_available():
100 gc.collect()
101 torch.xpu.empty_cache()
102 gc.collect()
103 elif is_torch_npu_available():
104 gc.collect()
105 torch.npu.empty_cache()
106 gc.collect()
107 elif torch.cuda.is_available():
108 gc.collect()
109 torch.cuda.empty_cache()
110 gc.collect()
111
112
113def randn_tensor(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected