[英]How to run Keras on GPU?
我正在尝试使用 GPU 在远程服务器上运行我的 ML 任务。我输入
英伟达-smi
我确定该设备有一个 GPU。
我正在使用 Keras 来编写我的 ML 任务。 我打算在一个 GPU 上运行我的任务。但我就是无法让程序在 GPU 上运行。我检查了正在运行的进程,但我的任务不是其中之一。
我试图在我的代码中使用多种方法打印出可用的设备,但它们没有显示我有一个 GPU。
从 tensorflow.python.client 导入 device_lib
打印(device_lib.list_local_devices())
这给了我:
[名称:“/device:CPU:0” device_type:“CPU” memory_limit:268435456 locality { }....
但没有显示“/device:GPU:0”
然后我尝试了:
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
这给了我:
可用的 GPU 数量:0
还,
print("GPUs:", tf.config.experimental.list_physical_devices('GPU'))
这给了我:
GPU:[]
和,
with tf.device("gpu:0"): print('-------------------------------------------') print("tf.keras code in this scope will run on GPU") print('-------------------------------------------')
这给了我:
------------------------------------------- tf.keras code in this scope will run on GPU -------------------------------------------
显然,我的代码没有在GPU上运行。不知道为什么它说我的Keras代码在GPU上运行。
我已经搜索了很多信息,但我仍然失败了。 我想知道如何在GPU上运行我的Keras代码,以及上面的情况是怎么回事。 提前致谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.