tensorflow - 尝试导入 tensorflow GPU 时出错
问题描述
这是我用来检查 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 一起使用,您必须安装 GPU 版本的 Tensorflow
python -m pip install tensorflow-gpu
确保您还使用 64 位版本的 python,因为它仅适用于这些参数。
编辑:
从 Tensorflow 2.0+ 开始,Tensorflow 的 CPU 和 GPU 版本已经打包在一起。
要让 Tensorflow 与您的 GPU 一起工作,您需要下载cuDNN。根据您拥有的 CUDA 版本,您需要在安装 CUDA 的文件位置放置一些头文件和一些 dll 文件。
推荐阅读
- python - 寻找数字河流的交汇点
- html - html/css .css 文件更改
- c# - VS 的诊断工具是测量总进程内存还是当前进程内存
- apache-kafka - kafka-server-start:该进程无法访问该文件,因为它正在被另一个进程使用
- python - Django:禁止为用户添加相同的数据
- byte - Http.get 中的 Elm 字节解码
- python - 只有文件列表的最后一个元素在 python 中使用 json.dump 输出
- state - Apache Beam 状态管理/处理 - 在窗口范围内跨 ParDo 共享状态?
- reactjs - 将子级用作函数时组件不呈现
- python - 如何在TF/Keras中实现滑动窗口模型进行图像分割?