Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZeroDivisionError: float division by zero in test_cpu_parallel #88

Open
pbelevich opened this issue Dec 2, 2020 · 3 comments
Open

ZeroDivisionError: float division by zero in test_cpu_parallel #88

pbelevich opened this issue Dec 2, 2020 · 3 comments
Labels
good first issue Good for newcomers

Comments

@pbelevich
Copy link
Contributor

@unittest.skipIf(torch.get_num_threads() < 2, "requires multithreading CPU")
    def test_cpu_parallel(self):
        urandom_gen = csprng.create_random_device_generator('/dev/urandom')
    
        def measure(size):
            t = torch.empty(size, dtype=torch.float32, device='cpu')
            start = time.time()
            for i in range(10):
                t.normal_(generator=urandom_gen)
            finish = time.time()
            return finish - start
    
        time_for_1K = measure(1000)
        time_for_1M = measure(1000000)
        # Pessimistic check that parallel execution gives >= 1.5 performance boost
>       self.assertTrue(time_for_1M/time_for_1K < 1000 / min(1.5, torch.get_num_threads()))
E       ZeroDivisionError: float division by zero

test\test_csprng.py:308: ZeroDivisionError
@pbelevich pbelevich added the good first issue Good for newcomers label Dec 2, 2020
@pbelevich
Copy link
Contributor Author

fixed

@pbelevich
Copy link
Contributor Author

@pbelevich pbelevich reopened this Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant