【发布时间】:2022-12-24 01:07:57
【问题描述】:
无法导入名称 'pywrap_dtensor_device' 来自 'tensorflow.python' (C:\python3\lib\site-packages\tensorflow\python_在里面.py
【问题讨论】:
标签: tensorflow
无法导入名称 'pywrap_dtensor_device' 来自 'tensorflow.python' (C:\python3\lib\site-packages\tensorflow\python_在里面.py
【问题讨论】:
标签: tensorflow
很容易有很多可能的方式,其中之一就是包含急切模式和非急切模式。
您可以为作业指定设备,因为具有基本配置的 Tensorflow 2.8 不需要 jobid *
他们管理日程安排,或者您可以使用经理。
[渴望模式]:
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 )
[无渴望模式]:
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 )
[ 输出 ]:
<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)
【讨论】: