这是我用来检查 tf.gpu 是否正常工作的代码
import tensorflow as tf
if tf.test.gpu_device_name():
print('Default GPU Device:{}'.format(tf.test.gpu_device_name()))
else:
print("Please install GPU version of TF")
这是错误
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
2020-11-22 21:53:40.971514: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-11-22 21:53:40.971756: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
要将 GPU 与 Tensorflow 一起使用,您必须安装 Tensorflow 的 GPU 版本
python -m pip install tensorflow-gpu
确保您还使用 64 位版本的 python,因为它只适用于这些参数。
编辑:
从 Tensorflow 2.0+ 开始,Tensorflow 的 CPU 和 GPU 版本都已打包在一起。
要让 Tensorflow 与您的 GPU 一起工作,您需要下载cuDNN。根据您拥有的 CUDA 版本,您需要在安装 CUDA 的文件位置放置一些头文件和一些 dll 文件。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句