安装Tensorflow安装问题记录

问题1:

pip安装时,提示找不到对应的版本“No matching distribution found ”c:\>pip install tensorflow-gpuCollecting tensorflow-gpu  Could not find a version that satisfies the requirement tensorflow-gpu (from versions: )No matching distribution found for tensorflow-gpu

解答:可用“python -m pip install tensorflow-gpu” 或者 “pip install 版本链接”

问题2:

FileNotFoundError: [WinError 3] 系统找不到指定的路径。: 'c:\\users\\administrator.chenbo-ovr097b6\\appdata\\local\\programs\\python\\python35-32\\lib\\site-packages\\pip\\_vendor\\requests\\packages\\urllib3\\packages\\ssl_match_hostname\\__pycache__\\__init__.cpython-35.pyc' -> 'C:\\Users\\ADMINI~1.CHE\\AppData\\Local\\Temp\\2\\pip-xsio8aj7-uninstall\\users\\administrator.chenbo-ovr097b6\\appdata\\local\\programs\\python\\python35-32\\lib\\site-packages\\pip\\_vendor\\requests\\packages\\urllib3\\packages\\ssl_match_hostname\\__pycache__\\__init__.cpython-35.pyc'

解答:重新配置环境变量问题

问题3:

安装python后,提示pip无法被执行,需要重新安装C:\Users\Administrator.chenbo-ovr097b6\AppData\Local\Programs\Python\Python35-32\python.exe: No module named pip.__main__; 'pip' is a package and cannot be directly executed

解答:python -m ensurepip

问题4:

找不到指定模块>>> import tensorflow as tfTraceback (most recent call last):  File "C:\Users\Administrator.chenbo-ovr097b6\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper    return importlib.import_module(mname)  File "C:\Users\Administrator.chenbo-ovr097b6\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module    return _bootstrap._gcd_import(name[level:], package, level)  File "", line 978, in _gcd_import  File "", line 961, in _find_and_load  File "", line 950, in _find_and_load_unlocked  File "", line 648, in _load_unlocked  File "", line 560, in module_from_spec  File "", line 922, in create_module  File "", line 205, in _call_with_frames_removedImportError: DLL load failed: 找不到指定的模块。During handling of the above exception, another exception occurred:Traceback (most recent call last):  File "C:\Users\Administrator.chenbo-ovr097b6\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, infrom tensorflow.python.pywrap_tensorflow_internal import *  File "C:\Users\Administrator.chenbo-ovr097b6\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in_pywrap_tensorflow_internal = swig_import_helper()

File "C:\Users\Administrator.chenbo-ovr097b6\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper

return importlib.import_module('_pywrap_tensorflow_internal')

File "C:\Users\Administrator.chenbo-ovr097b6\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

解答:

missing MSVCP140.dll,安装https://www.microsoft.com/en-us/download/details.aspx?id=53587

参考链接:https://github.com/tensorflow/tensorflow/issues/5949

问题5:

没有使用GPU进行加速

>>> import tensorflow as tf

>>> sess = tf.Session()

2017-09-18 14:57:45.014544: W C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.

2017-09-18 14:57:45.015422: W C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.

>>>

>>> sess = tf.Session()

>>> a = tf.constant(1)

>>> b = tf.constant(2)

>>> print(sess.run(a+b))

3

>>>

解答:

1.CPU的加速效果更好 --> 运行其他代码尝试

2.框架安装有问题,换成其他方式安装


问题6:

显存不够

>>> import tensorflow as tf

>>> hello = tf.constant('Hello, TensorFlow!')

>>> sess = tf.Session()

2017-09-18 18:47:48.550964: W C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow librarywasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.

2017-09-18 18:47:48.551931: W C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow librarywasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.

2017-09-18 18:47:49.117177: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:955] Found device 0 with

properties:

name: Tesla M60

major: 5 minor: 2 memoryClockRate (GHz) 1.1775

pciBusID 0000:00:15.0

Total memory: 8.00GiB

Free memory: 7.64GiB

2017-09-18 18:47:49.117837: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:976] DMA: 02017-09-18 18:47:49.121139: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:986] 0:  Y

2017-09-18 18:47:49.122430: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Tesla M60, pci bus id: 0000:00:15.0)

2017-09-18 18:47:49.265265: E C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_driver.cc:924] failed to allocate 7.

26G (7792089088 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY2017-09-18 18:47:49.401091: E C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_driver.cc:924] failed to allocate 6.

53G (7012879872 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY

2017-09-18 18:47:49.537186: E C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_driver.cc:924] failed to allocate 5.88G (6311591936 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY

2017-09-18 18:47:49.674310: E C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_driver.cc:924] failed to allocate 5.29G (5680432640 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY

2017-09-18 18:47:49.813375: E C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_driver.cc:924] failed to allocate 4.76G (5112389120 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY

2017-09-18 18:47:49.949057: E C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_driver.cc:924] failed to allocate 4.28G (4601149952 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY

2017-09-18 18:47:49.963002: E C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_driver.cc:924] failed to allocate 3.86G (4141034752 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY

2017-09-18 18:47:49.975810: E C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_driver.cc:924] failed to allocate 3.47G (3726931200 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY

>>> print(sess.run(hello))

b'Hello, TensorFlow!'

>>>

解决方法:

GPU的显存是按照core进行分配的,初次创建的时候,会尽可能分配更多的显存给框架,如果多个任务并行,就会出现显存争抢的问题,导致CUDA OOM

如果同时跑多个任务,则可以通过一下命令,修改没个session分配的缓存

config = tf.ConfigProto(log_device_placement=False, allow_soft_placement=True)

config.gpu_options.allow_growth=True

sess = tf.Session(config=config)

如果只跑一个任务,可能是驱动版本不对可以更新驱动尝试

Nvidia驱动for windows:http://www.nvidia.cn/content/DriverDownload-March2009/confirmation.php?url=/Windows/Quadro_Certified/385.08/385.08-tesla-desktop-winserver2008-2012r2-64bit-international-whql.exe&lang=cn&type=Tesla

http://cn.download.nvidia.com/Windows/Quadro_Certified/385.08/385.08-tesla-desktop-winserver2008-2012r2-64bit-international-whql.exe

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 162,050评论 4 370
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 68,538评论 1 306
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 111,673评论 0 254
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,622评论 0 218
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 53,047评论 3 295
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,974评论 1 224
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 32,129评论 2 317
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,893评论 0 209
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,654评论 1 250
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,828评论 2 254
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,297评论 1 265
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,619评论 3 262
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,326评论 3 243
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,176评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,975评论 0 201
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 36,118评论 2 285
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,909评论 2 278

推荐阅读更多精彩内容

  • 1. 介绍 首先让我们来看看TensorFlow! 但是在我们开始之前,我们先来看看Python API中的Ten...
    JasonJe阅读 11,621评论 1 32
  • 1c8b: 回顾与概述 这篇文章详细介绍了Tensorflow的安装和校验安装是否成功的教程,涵盖了在Ubuntu...
    darkie阅读 3,169评论 0 4
  • 网址 下载与安装 你可以使用我们提供的 Pip, Docker, Virtualenv, Anaconda 或 源...
    九七学姐阅读 4,650评论 3 11
  • 安装tensorflow 下载tensorflow源文件 Gitclone--recurse-submodules...
    风果阅读 1,864评论 0 2
  • 早上八点起开会到下午五点,大组会和锦囊会连着一起开的,挺累的。大组会上组员间相互贡献,分享各自的心得。大家都很努力...
    叶子卷阅读 327评论 0 1