简体   繁体   English

如何使用 GPU 运行 tensorflow?

[英]How to run tensorflow using GPU?

Tensorflow version - 1.0.1 GPU version - 1.0.1 python - 3.6 Graphics(Ubuntu 18.04) - Intel® Sandybridge Desktop We are trying to run a python code using Tensorflow. Tensorflow 版本 - 1.0.1 GPU 版本 - 1.0.1 python - 3.6 图形(Ubuntu 18.04) - 英特尔® Sandybridge 桌面 我们正在尝试使用 Tensorflow 运行 Python 代码。 But it was very slow.但它非常缓慢。 So, we would like to run the code on GPU.所以,我们想在 GPU 上运行代码。 Can anyone suggest how to use GPU for running python code?谁能建议如何使用 GPU 来运行 python 代码?

您可以卸载张量流并安装 GPU 兼容版本

pip install tensorflow-gpu
config = tf.compat.v1.ConfigProto(gpu_options = tf.compat.v1.GPUOptions(per_process_gpu_memory_fraction=0.8))
config.gpu_options.allow_growth = True
session = tf.compat.v1.Session(config=config)
tf.compat.v1.keras.backend.set_session(session)

Place this code before your python code and also make sure you have all the cuDNN dlls installed.将此代码放在您的 python 代码之前,并确保您已安装所有 cuDNN dll。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM