(self)
| 396 | @test_util.run_gpu_only |
| 397 | @reset_eager |
| 398 | def testGpuNone(self): |
| 399 | gpus = config.list_physical_devices('GPU') |
| 400 | self.assertGreater(len(gpus), 0) |
| 401 | |
| 402 | cpus = config.list_physical_devices('CPU') |
| 403 | self.assertEqual(len(cpus), 1) |
| 404 | |
| 405 | self.assertEqual(len(config.get_visible_devices('CPU')), 1) |
| 406 | self.assertGreater(len(config.get_visible_devices('GPU')), 0) |
| 407 | config.set_visible_devices(cpus[0]) |
| 408 | self.assertEqual(len(config.get_visible_devices('CPU')), 1) |
| 409 | self.assertEqual(len(config.get_visible_devices('GPU')), 0) |
| 410 | |
| 411 | with self.assertRaisesRegexp(RuntimeError, 'unknown device'): |
| 412 | with ops.device('/device:GPU:0'): |
| 413 | a = constant_op.constant(1.0) |
| 414 | self.evaluate(a) |
| 415 | |
| 416 | # Modifying the visible devices is not supported |
| 417 | with self.assertRaisesRegexp(RuntimeError, 'cannot be modified'): |
| 418 | config.set_visible_devices(gpus) |
| 419 | |
| 420 | # Setting the same visible devices is fine |
| 421 | config.set_visible_devices(cpus[0]) |
| 422 | |
| 423 | @reset_eager |
| 424 | def testGpuMultiple(self): |
nothing calls this directly
no test coverage detected