mirror of
https://github.com/zebrajr/pytorch.git
synced 2026-01-15 12:15:51 +00:00
Summary: Reland of the benchmark code that broke the slow tests because the GPU were running out of memory Pull Request resolved: https://github.com/pytorch/pytorch/pull/43428 Reviewed By: ngimel Differential Revision: D23296136 Pulled By: albanD fbshipit-source-id: 0002ae23dc82f401604e33d0905d6b9eedebc851
58 lines
2.3 KiB
Python
58 lines
2.3 KiB
Python
from torch.testing._internal.common_utils import TestCase, run_tests, slowTest, IS_WINDOWS
|
|
|
|
import subprocess
|
|
import tempfile
|
|
import os
|
|
import unittest
|
|
|
|
# This is a very simple smoke test for the functional autograd benchmarking script.
|
|
class TestFunctionalAutogradBenchmark(TestCase):
|
|
def _test_runner(self, model, disable_gpu=False):
|
|
# Note about windows:
|
|
# The temporary file is exclusively open by this process and the child process
|
|
# is not allowed to open it again. As this is a simple smoke test, we choose for now
|
|
# not to run this on windows and keep the code here simple.
|
|
with tempfile.NamedTemporaryFile() as out_file:
|
|
cmd = ['python', '../benchmarks/functional_autograd_benchmark/functional_autograd_benchmark.py']
|
|
# Only run the warmup
|
|
cmd += ['--num-iters', '0']
|
|
# Only run the vjp task (fastest one)
|
|
cmd += ['--task-filter', 'vjp']
|
|
# Only run the specified model
|
|
cmd += ['--model-filter', model]
|
|
# Output file
|
|
cmd += ['--output', out_file.name]
|
|
if disable_gpu:
|
|
cmd += ['--gpu', '-1']
|
|
|
|
res = subprocess.run(cmd)
|
|
|
|
self.assertTrue(res.returncode == 0)
|
|
# Check that something was written to the file
|
|
out_file.seek(0, os.SEEK_END)
|
|
self.assertTrue(out_file.tell() > 0)
|
|
|
|
|
|
@unittest.skipIf(IS_WINDOWS, "NamedTemporaryFile on windows does not have all the features we need.")
|
|
def test_fast_tasks(self):
|
|
fast_tasks = ['resnet18', 'ppl_simple_reg', 'ppl_robust_reg', 'wav2letter',
|
|
'transformer', 'multiheadattn']
|
|
|
|
for task in fast_tasks:
|
|
self._test_runner(task)
|
|
|
|
@slowTest
|
|
@unittest.skipIf(IS_WINDOWS, "NamedTemporaryFile on windows does not have all the features we need.")
|
|
def test_slow_tasks(self):
|
|
slow_tasks = ['fcn_resnet', 'detr']
|
|
# deepspeech is voluntarily excluded as it takes too long to run without
|
|
# proper tuning of the number of threads it should use.
|
|
|
|
for task in slow_tasks:
|
|
# Disable GPU for slow test as the CI GPU don't have enough memory
|
|
self._test_runner(task, disable_gpu=True)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
run_tests()
|