无法从'tensorflow '中导入名称'pywrap_dtensor_device'。python"(C: python3 lib 网站 tensorflow python_init. py
这很简单,有很多可能的方法,其中之一就是你包含了急切模式和非急切模式。
您可以为作业指定设备,因为带有基本配置的Tensorflow 2.8不需要jobid *
他们管理日程安排,或者你可以使用经理。
[Eager mode]:
device_spec = DeviceSpec(device_type="GPU", device_index=0)
print( device_spec )
print( device_spec.to_string() )
with tf.device(device_spec.to_string()):
my_var = tf.Variable(1.)
squared_var = tf.square(my_var)
print( squared_var )
[None Eager mode]:
tf.compat.v1.disable_eager_execution()
device_spec = DeviceSpec(job="1234", device_type="GPU", device_index=0)
print( device_spec )
print( device_spec.to_string() )
with tf.device(device_spec.to_string()):
my_var = tf.Variable(1.)
squared_var = tf.square(my_var)
print( squared_var )
[Output]:
<tensorflow.python.framework.device_spec.DeviceSpecV2 object at 0x000001AB1149EBE0>
/job:1234/device:GPU:0
Tensor("Square:0", shape=(), dtype=float32, device=/job:1234/device:GPU:0)