【发布时间】:2021-09-25 20:36:25
【问题描述】:
我正在尝试让 tensorflow 与我的 GPU 对话,这样我就可以更快地对我的神经网络进行建模。我已经使用 pip 安装了 tensorflow-gpu 和 cuDNN,并且我已经安装了驱动程序和 cuda。我检查了 tensorflow 是否可以使用以下方式查看我的 GPU:
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
它返回的:
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 5916901003862901746
, name: "/device:GPU:0"
device_type: "GPU"
memory_limit: 4848943104
locality {
bus_id: 1
links {
}
}
incarnation: 16957123506888322798
physical_device_desc: "device: 0, name: NVIDIA GeForce GTX 1060 6GB, pci bus id:
0000:01:00.0, compute capability: 6.1"
]
所以我猜它找到了我的 GPU。并使用以下命令检查 cuda:
import tensorflow as tf
print(tf.test.is_built_with_cuda())
返回 True 所以它找到了 cuda 安装。但是当我尝试初始化它时:
sess = tf.compat.v1.Session()
tf.compat.v1.disable_eager_execution()
sess.run(tf.compat.v1.global_variables_initializer())
我得到一个无效的论点:
InvalidArgumentError: Cannot assign a device for operation assert_greater_3/Assert/Const:
Could not satisfy explicit device specification '/device:GPU:0' because no supported kernel
for GPU devices is available.
Colocation Debug Info:
Colocation group had the following types and supported devices:
Root Member(assigned_device_name_index_=-1 requested_device_name_='/device:GPU:0'
assigned_device_name_='' resource_device_name_='' supported_device_types_=[CPU]
possible_devices_=[]
Const: CPU
Colocation members, user-requested devices, and framework assigned devices, if any:
assert_greater_3/Assert/Const (Const) /device:GPU:0
然后它回退到使用我的 CPU。
除了缺少内核外,我不太了解错误消息。我试图在网上寻找错误,但没有任何结果。有没有其他人遇到过这样的事情并且知道方法?
【问题讨论】:
-
如果可能的话,我建议忽略
TF 1.x,而改用TF 2.X,最好是2.5。 -
@Chi 你用的是哪个版本的TensorFlow?
-
嗨 Swaroop,它是 tf 2.5
-
import tensorflow之后,您是否收到任何警告或消息? -
嗨,Dominik,不,一切都好。
标签: python tensorflow gpu