[Refactor] Replace and ban a few torch.cuda functions in favor of torch.accelerator replacements. (#3365)

Signed-off-by: Nick Cao <ncao@redhat.com>
This commit is contained in:
Nick Cao authored and GitHub committed 2026-05-07 23:23:59 +08:00
1 parent 54277a8dd0
commit e6466cf0e6
40 files changed
+98 -90

No files matched your search

+3 -3
View File
@@ -130,7 +130,7 @@ def wait_for_gpu_memory_to_clear(
)
gc.collect()
torch.cuda.empty_cache()
torch.accelerator.empty_cache()
time.sleep(5)
@@ -244,7 +244,7 @@ def run_pre_test_cleanup(enable_force: bool = False) -> None:
print("Pre-test GPU status:")
num_gpus = torch.cuda.device_count()
num_gpus = torch.accelerator.device_count()
if num_gpus > 0:
try:
wait_for_gpu_memory_to_clear(
@@ -262,7 +262,7 @@ def run_post_test_cleanup(enable_force: bool = False) -> None:
if torch.cuda.is_available():
gc.collect()
torch.cuda.empty_cache()
torch.accelerator.empty_cache()
print("Post-test GPU status:")
_print_gpu_processes()