MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testGpuNone

Method testGpuNone

tensorflow/python/framework/config_test.py:398–421  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 6

list_physical_devicesMethod · 0.80
get_visible_devicesMethod · 0.80
set_visible_devicesMethod · 0.45
deviceMethod · 0.45
constantMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected