tensorflow - 在 GPU 上运行 TensorFlow 2.0 的正确方法是什么?
问题描述
我在没有 AVX 的 Windows 10 PC 上使用这些命令执行此操作,仅支持 SSE4.2、GTX1060 6GB 和最新驱动程序:
conda create --name tensorflow-2.0 python=3.6
activate tensorflow-2.0
pip install tf-nightly-gpu-2.0-preview
conda install -c anaconda cudatoolkit
conda install -c anaconda cudnn
一切都很好,直到我尝试使用 TensorFlow:
import tensorflow as tf
ImportError: Traceback (most recent call last):
File "C:\Users\Frut\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Frut\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Frut\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\Frut\Anaconda3\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Frut\Anaconda3\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: Не найден указанный модуль.
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.
我尝试了另一种方法:
conda remove -n tensorflow-2.0 --all
删除了“Anaconda3\envs”中的文件夹“tensorflow-2.0”
conda create --name tensorflow-2.0 python=3.6
conda activate tensorflow-2.0 && conda install -c anaconda pip
之后没有错误,但活动环境仍然是“base *”
activate tensorflow-2.0
现在活动环境是 tensorflow-2.0
conda install -c anaconda cudatoolkit
conda install -c anaconda cudnn
pip install tensorflow-gpu==2.0.0-alpha0
结果是同样的错误:
import tensorflow as tf
Failed to load the native TensorFlow runtime
解决方案
文档当前建议使用此命令安装支持 GPU 的 Tensorflow2.0:
$ pip install tensorflow-gpu==2.0.0-alpha0
为了在里面安装它conda
(假设你有启用 CUDA 的硬件),你必须pip
首先在环境中安装它:
$ conda activate your_environment && conda install -c anaconda pip
之后发出 pip 命令。如果我是你,我会破坏这个环境,只是为了确定并从头开始创建它。
推荐阅读
- java - 发送邮件未收到
- excel - 将动态范围与另一个工作簿中的动态范围进行比较并获得价值
- prolog - 从 prolog 谓词中获得多个答案
- kubernetes - NGINX Ingress Controller 隐藏 Nginx 版本
- sql - 查找按月汇总的滚动总计
- r - 如果另一个 Dataframe 值小于 0,则替换 R Dataframe 中的值
- django - 如果我的数据中不存在查询值,为什么 DjangoFilterBackend 不返回任何结果?
- tensorflow - 带有 TFrecords 的 GoogleML 上的 TensorFlow:OutOfRangeError(有关回溯,请参见上文):序列结束
- regex - 处理误报正则表达式
- python - 清除 python 控制台命令历史记录