安裝Tensorflow安裝問題記錄

問題1:

pip安裝時(shí),提示找不到對應(yīng)的版本“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] 系統(tǒng)找不到指定的路徑。: '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'

解答:重新配置環(huán)境變量問題

問題3:

安裝python后,提示pip無法被執(zhí)行,需要重新安裝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進(jìn)行加速

>>> 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的加速效果更好 --> 運(yùn)行其他代碼嘗試

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進(jìn)行分配的,初次創(chuàng)建的時(shí)候,會(huì)盡可能分配更多的顯存給框架,如果多個(gè)任務(wù)并行,就會(huì)出現(xiàn)顯存爭搶的問題,導(dǎo)致CUDA OOM

如果同時(shí)跑多個(gè)任務(wù),則可以通過一下命令,修改沒個(gè)session分配的緩存

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

config.gpu_options.allow_growth=True

sess = tf.Session(config=config)

如果只跑一個(gè)任務(wù),可能是驅(qū)動(dòng)版本不對可以更新驅(qū)動(dòng)嘗試

Nvidia驅(qū)動(dòng)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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1. 介紹 首先讓我們來看看TensorFlow! 但是在我們開始之前,我們先來看看Python API中的Ten...
    JasonJe閱讀 11,969評論 1 32
  • 1c8b: 回顧與概述 這篇文章詳細(xì)介紹了Tensorflow的安裝和校驗(yàn)安裝是否成功的教程,涵蓋了在Ubuntu...
    darkie閱讀 3,326評論 0 4
  • 網(wǎng)址 下載與安裝 你可以使用我們提供的 Pip, Docker, Virtualenv, Anaconda 或 源...
    九七學(xué)姐閱讀 4,904評論 3 11
  • 安裝tensorflow 下載tensorflow源文件 Gitclone--recurse-submodules...
    風(fēng)果閱讀 2,019評論 0 2
  • 早上八點(diǎn)起開會(huì)到下午五點(diǎn),大組會(huì)和錦囊會(huì)連著一起開的,挺累的。大組會(huì)上組員間相互貢獻(xiàn),分享各自的心得。大家都很努力...
    葉子卷閱讀 392評論 0 1

友情鏈接更多精彩內(nèi)容