TensorFlow DeepLab教程初稿-tensorflow gpu安装教程

时间:2022-09-21 23:18:45

TensorFlow DeepLab教程初稿-tensorflow gpu安装教程

商务合作,科技咨询,版权转让:向日葵,135—4855__4328,xiexiaokui#qq.com

Summary: DeepLab需要1.10以上版本。

本日志详细记录在两台不同笔记本电脑安装/更新 TensorFlow-GPU的具体过程

这是本人第3次,4次安装tf,这两次是gpu版。

第一次是安装cpu版,第二次是在python2.7 arcpy环境下安装32位 tf,但不能运行。第三次安装成功,但电脑配置过低,只能使用cpu功能;第四次安装成功,可以正确运行,使用gpu。

向日葵2019年7月24日于长沙

Confirm tensorflow installed correctly

>>> import
tensorflow
as
tf

>>> hello=tf.constant("Hello tf")

>>> tf.Session().run(hello)

b'Hello tf'

 

查看tf版本

C:\Users\think>python --version

Python 3.6.7 :: Anaconda custom (64-bit)

 

Anaconda3 (3.6, 64-bit) interactive window [PTVS 16.0.19074.1-16.0]

Type $help for a list of commands.

>>> import
tensorflow
as
tf

>>> tf.VERSION

'1.12.0'

>>>

 

>>> tf.__version__

'1.12.0'

 

查看CPU GPU版本

import
os

from
tensorflow.python.client
import
device_lib

os.environ["TF_CPP_MIN_LOG_LEVEL"]="99"

device_lib.list_local_devices()

 

[name: "/device:CPU:0"

device_type: "CPU"

memory_limit: 268435456

locality {

}

incarnation: 5642870862507944

]

>>> if __name__ == "main":

... print(device_lib.list_local_devices)

...

>>>

 

查看python安装路径

>>> import
sys

>>> sys.path

['.', 'D:\\ProgramData\\Anaconda3\\', 'd:\\ProgramData\\Anaconda3\\python36.zip', 'd:\\ProgramData\\Anaconda3\\DLLs', 'd:\\ProgramData\\Anaconda3\\lib', 'd:\\ProgramData\\Anaconda3', 'd:\\ProgramData\\Anaconda3\\lib\\site-packages', 'd:\\ProgramData\\Anaconda3\\lib\\site-packages\\win32', 'd:\\ProgramData\\Anaconda3\\lib\\site-packages\\win32\\lib', 'd:\\ProgramData\\Anaconda3\\lib\\site-packages\\Pythonwin']

 

>>> import
os

>>> os.path

<module 'ntpath' from 'd:\\ProgramData\\Anaconda3\\lib\\ntpath.py'>

Python.exe的路径:

"D:\ProgramData\Anaconda3\python.exe"

 

TensorFlow DeepLab教程初稿-tensorflow gpu安装教程

 

更新为gpu版本

Type cmd to enter dos command line and type:

pip3 install --ignore-installed --upgrade tensorflow-gpu

 

C:\Users\think>pip3 install --ignore-installed --upgrade tensorflow-gpu

Collecting tensorflow-gpu

Downloading https://files.pythonhosted.org/packages/c7/e8/f7ba3acc4e45bea553ef085846e0240daa71986a04e1819bafef569f055b/tensorflow_gpu-1.14.0-cp36-cp36m-win_amd64.whl (287.7MB)

 

由于空间原因,安装失败。

Installing collected packages: astor, wheel, wrapt, six, setuptools, protobuf, numpy, google-pasta, termcolor, grpcio, h5py, keras-applications, absl-py, keras-preprocessing, gast, tensorflow-estimator, markdown, werkzeug, tensorboard, tensorflow-gpu

Could not install packages due to an EnvironmentError: [Errno 28] No space left on device

重输入命令,可以续装,自动使用缓存。

 

tensorflow 1.12.0 has requirement tensorboard<1.13.0,>=1.12.0, but you'll have tensorboard 1.14.0 which is incompatible.

 

Installing collected packages: six, setuptools, protobuf, numpy, h5py, keras-applications, absl-py, grpcio, tensorflow-estimator, termcolor, google-pasta, wrapt, wheel, gast, werkzeug, markdown, tensorboard, astor, keras-preprocessing, tensorflow-gpu

Successfully installed absl-py-0.7.1 astor-0.8.0 gast-0.2.2 google-pasta-0.1.7 grpcio-1.22.0 h5py-2.9.0 keras-applications-1.0.8 keras-preprocessing-1.1.0 markdown-3.1.1 numpy-1.16.4 protobuf-3.9.0 setuptools-41.0.1 six-1.12.0 tensorboard-1.14.0 tensorflow-estimator-1.14.0 tensorflow-gpu-1.14.0 termcolor-1.1.0 werkzeug-0.15.5 wheel-0.33.4 wrapt-1.11.2

 

尝试卸载

C:\Users\think>pip3 uninstall tensorflow

Uninstalling tensorflow-1.12.0:

Would remove:

d:\programdata\anaconda3\lib\site-packages\tensorflow-1.12.0.dist-info\*

 

Proceed (y/n)? y

Successfully uninstalled tensorflow-1.12.0

成功卸载

 

重新尝试安装gpu版本:

C:\Users\think>pip3 install --ignore-installed --upgrade tensorflow-gpu

Collecting tensorflow-gpu

Using cached https://files.pythonhosted.org/packages/c7/e8/f7ba3acc4e45bea553ef085846e0240daa71986a04e1819bafef569f055b/tensorflow_gpu-1.14.0-cp36-cp36m-win_amd64.whl

 

开始使用缓存安装

结果TensorFlow-gpu 安装成功

 

测试tf

C:\Users\think>python

Python 3.6.7 |Anaconda custom (64-bit)| (default, Oct 28 2018, 19:44:12) [MSC v.1915 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> import tensorflow as tf

D:\ProgramData\Anaconda3\lib\site-packages\numpy\core\__init__.py:29: UserWarning: loaded more than 1 DLL from .libs:

D:\ProgramData\Anaconda3\lib\site-packages\numpy\.libs\libopenblas.CSRRD7HKRKC3T3YXA7VY7TAZGLSWDKW6.gfortran-win_amd64.dll

D:\ProgramData\Anaconda3\lib\site-packages\numpy\.libs\libopenblas.TXA6YQSD3GCQQC22GEQ54J2UDCXDXHWN.gfortran-win_amd64.dll

stacklevel=1)

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 28, in <module>

from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 47, in <module>

import numpy as np

File "D:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>

from . import core

File "D:\ProgramData\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 91, in <module>

raise ImportError(msg.format(path))

ImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['D:\\ProgramData\\Anaconda3\\lib\\site-packages\\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.

 

Uninstall numpy

C:\Users\think>pip3 uninstall numpy

Uninstalling numpy-1.16.4:

Would remove:

d:\programdata\anaconda3\lib\site-packages\numpy-1.16.4.dist-info\*

d:\programdata\anaconda3\lib\site-packages\numpy\*

d:\programdata\anaconda3\scripts\f2py.exe

Would not remove (might be manually added):

d:\programdata\anaconda3\lib\site-packages\numpy\.libs\libopenblas.CSRRD7HKRKC3T3YXA7VY7TAZGLSWDKW6.gfortran-win_amd64.dll

d:\programdata\anaconda3\lib\site-packages\numpy\_import_tools.py

d:\programdata\anaconda3\lib\site-packages\numpy\_mklinit.cp36-win_amd64.pyd

d:\programdata\anaconda3\lib\site-packages\numpy\add_newdocs.py

d:\programdata\anaconda3\lib\site-packages\numpy\core\multiarray.cp36-win_amd64.pyd

d:\programdata\anaconda3\lib\site-packages\numpy\core\umath.cp36-win_amd64.pyd

d:\programdata\anaconda3\lib\site-packages\numpy\distutils\environment.py

d:\programdata\anaconda3\lib\site-packages\numpy\distutils\site.cfg

d:\programdata\anaconda3\lib\site-packages\numpy\random_intel\__init__.py

d:\programdata\anaconda3\lib\site-packages\numpy\random_intel\setup.py

d:\programdata\anaconda3\lib\site-packages\numpy\testing\_private\pytesttester.py

Proceed (y/n)? y

Successfully uninstalled numpy-1.16.4

 

Install numpy

C:\Users\think>pip3 install numpy

Requirement already satisfied: numpy in d:\programdata\anaconda3\lib\site-packages (1.15.4)

 

测试tf

>>> import tensorflow as tf

Traceback (most recent call last):

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\platform\self_check.py", line 75, in preload_check

ctypes.WinDLL(build_info.cudart_dll_name)

File "D:\ProgramData\Anaconda3\lib\ctypes\__init__.py", line 348, in __init__

self._handle = _dlopen(self._name, mode)

OSError: [WinError 126] The specified module could not be found

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 28, in <module>

from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>

from tensorflow.python import pywrap_tensorflow

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 30, in <module>

self_check.preload_check()

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\platform\self_check.py", line 82, in preload_check

% (build_info.cudart_dll_name, build_info.cuda_version_number))

ImportError: Could not find 'cudart64_100.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 10.0 from this URL: https://developer.nvidia.com/cuda-90-download-archive(tf提示错误:应为https://developer.nvidia.com/cuda-100-download-archive)

结果:

1. 找不到cuda v10.0

2. tf安装程序的提示版本错误,但提示的dll版本信息是正确的。

由于已经安装了最新版的cuda,查看版本及文件名

G:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin

cudart64_101.dll

 

TensorFlow DeepLab教程初稿-tensorflow gpu安装教程

 

结果:已安装cuda版本过高。

重新安装cuda v10.0

查看环境变量:

path

G:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\V10.0\bin

G:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\V10.0\libnvvp

 

CUDA_PATH

G:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\V10.0

 

CUDA_PATH_V10_0

G:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\V10.0

 

 

Test tensorflow

>>> import tensorflow as tf

Traceback (most recent call last):

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>

from tensorflow.python.pywrap_tensorflow_internal import *

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>

_pywrap_tensorflow_internal = swig_import_helper()

File "D:\ProgramData\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 "D:\ProgramData\Anaconda3\lib\imp.py", line 243, in load_module

return load_dynamic(name, filename, file)

File "D:\ProgramData\Anaconda3\lib\imp.py", line 343, in load_dynamic

return _load(spec)

ImportError: DLL load failed: The specified procedure could not be found.

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 28, in <module>

from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>

from tensorflow.python import pywrap_tensorflow

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>

raise ImportError(msg)

ImportError: Traceback (most recent call last):

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>

from tensorflow.python.pywrap_tensorflow_internal import *

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>

_pywrap_tensorflow_internal = swig_import_helper()

File "D:\ProgramData\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 "D:\ProgramData\Anaconda3\lib\imp.py", line 243, in load_module

return load_dynamic(name, filename, file)

File "D:\ProgramData\Anaconda3\lib\imp.py", line 343, in load_dynamic

return _load(spec)

ImportError: DLL load failed: The specified procedure could not be found.

 

 

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.

 

Reinstall cudnn

安装cuDNN

官网下载好后可以直接解压文件夹。然后将这个文件夹下的文件按照如下操作复制到CUDA路径下:

 

Copy  <installpath>\cuda\bin\cudnn64_*.dll     to    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\ v10.0\bin.

Copy  <installpath>\cuda\ include\cudnn.h    to    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\ v10.0\include.

Copy  <installpath>\cuda\lib\x64\cudnn.lib    to    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib\x64.

 

测试:

>>> import tensorflow as tf

Traceback (most recent call last):

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>

from tensorflow.python.pywrap_tensorflow_internal import *

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>

_pywrap_tensorflow_internal = swig_import_helper()

File "D:\ProgramData\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 "D:\ProgramData\Anaconda3\lib\imp.py", line 243, in load_module

return load_dynamic(name, filename, file)

File "D:\ProgramData\Anaconda3\lib\imp.py", line 343, in load_dynamic

return _load(spec)

ImportError: DLL load failed: The specified procedure could not be found.

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 28, in <module>

from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>

from tensorflow.python import pywrap_tensorflow

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>

raise ImportError(msg)

ImportError: Traceback (most recent call last):

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>

from tensorflow.python.pywrap_tensorflow_internal import *

File "D:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>

_pywrap_tensorflow_internal = swig_import_helper()

File "D:\ProgramData\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 "D:\ProgramData\Anaconda3\lib\imp.py", line 243, in load_module

return load_dynamic(name, filename, file)

File "D:\ProgramData\Anaconda3\lib\imp.py", line 343, in load_dynamic

return _load(spec)

ImportError: DLL load failed: The specified procedure could not be found.

 

 

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.

结果:依然出错

卸载

C:\Users\think>pip3 uninstall tensorflow-gpu

Uninstalling tensorflow-gpu-1.14.0:

Would remove:

d:\programdata\anaconda3\lib\site-packages\tensorflow\*

d:\programdata\anaconda3\lib\site-packages\tensorflow_gpu-1.14.0.dist-info\*

d:\programdata\anaconda3\scripts\freeze_graph.exe

d:\programdata\anaconda3\scripts\saved_model_cli.exe

d:\programdata\anaconda3\scripts\tensorboard.exe

d:\programdata\anaconda3\scripts\tf_upgrade_v2.exe

d:\programdata\anaconda3\scripts\tflite_convert.exe

d:\programdata\anaconda3\scripts\toco.exe

d:\programdata\anaconda3\scripts\toco_from_protos.exe

 

Run python3.7 installed with vs

pythonpath

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64

 

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Scripts

 

 

重装

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Scripts>pip3 install tensorflow-gpu

Collecting tensorflow-gpu

Downloading https://files.pythonhosted.org/packages/81/d1/9222b9aac2fa27dccaef38917cde84c24888f3cd0dd139c7e12be9f49a7a/tensorflow_gpu-1.14.0-cp37-cp37m-win_amd64.whl (287.7MB)

 

Installing collected packages: tensorflow-estimator, google-pasta, numpy, six, grpcio, astor, wheel, wrapt, gast, absl-py, setuptools, werkzeug, protobuf, markdown, tensorboard, h5py, keras-applications, keras-preprocessing, termcolor, tensorflow-gpu

Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\program files (x86)\\microsoft visual studio\\shared\\python37_64\\Lib\\site-packages\\tensorflow_estimator'

Consider using the `--user` option or check the permissions.

 

You are using pip version 18.1, however version 19.2.1 is available.

You should consider upgrading via the 'python -m pip install --upgrade pip' command.

 

TensorFlow DeepLab教程初稿-tensorflow gpu安装教程

 

更新pip

结果:失败

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64>python -m pip install --upgrade pip

Collecting pip

Downloading https://files.pythonhosted.org/packages/62/ca/94d32a6516ed197a491d17d46595ce58a83cbb2fca280414e57cd86b84dc/pip-19.2.1-py2.py3-none-any.whl (1.4MB)

100% |████████████████████████████████| 1.4MB 6.0MB/s

Installing collected packages: pip

Found existing installation: pip 18.1

Uninstalling pip-18.1:

Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\program files (x86)\\microsoft visual studio\\shared\\python37_64\\lib\\site-packages\\pip-18.1.dist-info\\entry_points.txt'

Consider using the `--user` option or check the permissions.

 

You are using pip version 18.1, however version 19.2.1 is available.

You should consider upgrading via the 'python -m pip install --upgrade pip' command.

 

设置所有权限

重新更新pip

结果:成功

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64>python -m pip install --upgrade pip

Collecting pip

Using cached https://files.pythonhosted.org/packages/62/ca/94d32a6516ed197a491d17d46595ce58a83cbb2fca280414e57cd86b84dc/pip-19.2.1-py2.py3-none-any.whl

Installing collected packages: pip

Found existing installation: pip 18.1

Uninstalling pip-18.1:

Successfully uninstalled pip-18.1

Successfully installed pip-19.2.1

 

 

重新安装tf-gpu

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64>cd C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Scripts

 

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Scripts>pip3 install tensorflow-gpu

Collecting tensorflow-gpu

Using cached https://files.pythonhosted.org/packages/81/d1/9222b9aac2fa27dccaef38917cde84c24888f3cd0dd139c7e12be9f49a7a/tensorflow_gpu-1.14.0-cp37-cp37m-win_amd64.whl

 

WARNING: The script f2py.exe is installed in 'c:\program files (x86)\microsoft visual studio\shared\python37_64\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Running setup.py install for wrapt ... done

Found existing installation: setuptools 40.6.2

Uninstalling setuptools-40.6.2:

Successfully uninstalled setuptools-40.6.2

WARNING: The script wheel.exe is installed in 'c:\program files (x86)\microsoft visual studio\shared\python37_64\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Running setup.py install for absl-py ... done

WARNING: The script markdown_py.exe is installed in 'c:\program files (x86)\microsoft visual studio\shared\python37_64\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

WARNING: The script tensorboard.exe is installed in 'c:\program files (x86)\microsoft visual studio\shared\python37_64\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Running setup.py install for termcolor ... done

Running setup.py install for gast ... done

WARNING: The scripts freeze_graph.exe, saved_model_cli.exe, tensorboard.exe, tf_upgrade_v2.exe, tflite_convert.exe, toco.exe and toco_from_protos.exe are installed in 'c:\program files (x86)\microsoft visual studio\shared\python37_64\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Successfully installed absl-py-0.7.1 astor-0.8.0 gast-0.2.2 google-pasta-0.1.7 grpcio-1.22.0 h5py-2.9.0 keras-applications-1.0.8 keras-preprocessing-1.1.0 markdown-3.1.1 numpy-1.16.4 protobuf-3.9.0 setuptools-41.0.1 six-1.12.0 tensorboard-1.14.0 tensorflow-estimator-1.14.0 tensorflow-gpu-1.14.0 termcolor-1.1.0 werkzeug-0.15.5 wheel-0.33.4 wrapt-1.11.2

 

添加path环境变量

c:\program files (x86)\microsoft visual studio\shared\python37_64\Scripts

 

 

测试tf

>>> import tensorflow as tf

>>> tf.__version__

'1.14.0'

结果:成功

 

测试cpu还是gpu

>>> import os

>>> from tensorflow.python.client import device_lib

>>> os.environ["TF_CPP_MIN_LOG_LEVEL"]="99"

>>> device_lib.list_local_devices()

[name: "/device:CPU:0"

device_type: "CPU"

memory_limit: 268435456

locality {

}

incarnation: 11073789457534317226

]

 

测试是否在gpu上运行

>>> import tensorflow as tf

>>> sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

2019-07-24 18:55:42.319137: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

2019-07-24 18:55:42.324349: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library nvcuda.dll

2019-07-24 18:55:42.859900: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties:

name: Quadro K1100M major: 3 minor: 0 memoryClockRate(GHz): 0.7055

pciBusID: 0000:01:00.0

2019-07-24 18:55:42.864411: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.

2019-07-24 18:55:42.869847: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1717] Ignoring visible gpu device (device: 0, name: Quadro K1100M, pci bus id: 0000:01:00.0, compute capability: 3.0) with Cuda compute capability 3.0. The minimum required Cuda capability is 3.5.

2019-07-24 18:55:42.902715: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconnect StreamExecutor with strength 1 edge matrix:

2019-07-24 18:55:42.905383: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187] 0

2019-07-24 18:55:42.907013: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0: N

Device mapping: no known devices.

2019-07-24 18:55:42.910171: I tensorflow/core/common_runtime/direct_session.cc:296] Device mapping:

结果:

由于tf 最小cuda计算能力要求为3.5,本gpu(device: 0, name: Quadro K1100M, pci bus id: 0000:01:00.0, compute capability: 3.0)不满足要求。

 

换台电脑,在python3.6上安装tf-gpu

主要内容:

1. 添加权限

2 安装cuda,cudnn

3 根据提示更新pip

4 安装tf-gpu

 

测试是否在gpu上运行

>>> import tensorflow as tf

>>> sess=tf.Session(config=tf.ConfigProto(log_device_placement=True))

2019-07-24 19:05:52.174361: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

2019-07-24 19:05:52.180939: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library nvcuda.dll

2019-07-24 19:05:52.309641: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties:

name: GeForce 940MX major: 5 minor: 0 memoryClockRate(GHz): 1.2415

pciBusID: 0000:01:00.0

2019-07-24 19:05:52.317307: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.

2019-07-24 19:05:52.322696: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0

2019-07-24 19:05:53.599442: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconnect StreamExecutor with strength 1 edge matrix:

2019-07-24 19:05:53.603636: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187] 0

2019-07-24 19:05:53.605884: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0: N

2019-07-24 19:05:53.608481: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1391 MB memory) -> physical GPU (device: 0, name: GeForce 940MX, pci bus id: 0000:01:00.0, compute capability: 5.0)

Device mapping:

/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce 940MX, pci bus id: 0000:01:00.0, compute capability: 5.0

2019-07-24 19:05:53.618489: I tensorflow/core/common_runtime/direct_session.cc:296] Device mapping:

/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce 940MX, pci bus id: 0000:01:00.0, compute capability: 5.0

进一步测试

>>> import
os

>>> from
tensorflow.python.client
import
device_lib

>>> os.environ["TF_CPP_MIN_LOG_LEVEL"] = "99"

>>> print(device_lib.list_local_devices())

[name: "/device:CPU:0"

device_type: "CPU"

memory_limit: 268435456

locality {

}

incarnation: 2949566760586279955

,

 

name: "/device:GPU:0"

device_type: "GPU"

memory_limit: 1459018137

locality {

bus_id: 1

links {

}

}

incarnation: 14182985404273149922

physical_device_desc: "device: 0, name: GeForce 940MX, pci bus id: 0000:01:00.0, compute capability: 5.0"

]

 

总结

在anaconda3.6安装最新版(未指定版本)tf-gpu,失败。因为没有提示具体错误,难以分析具体原因,所以拟在别的位置的python上重新安装。

失败的原因可能是在本python下已经安装了tf cpu '1.12.0'

找到vs安装的python3.7,添加环境变量和权限后,更新pip命令,未指定版本, '1.14.0',安装成功,发现下载速度很快,一会儿就安装好了,但不能正确运行。

之后换位置安装好,但gpu版本太低,无法应用gpu加速。

最后换电脑安装,终于成功。

结论:

1. 查看gpu-cuda计算能力,是否大于3.5

2. 如果python安装c盘,需要添加权限

3 更新pip

4. 安装tf-gpu,目前最新版为1.14.0

5.安装cuda和cudnn,需要完全核定版本,这一步可以根据运行tf的结果来确认版本。

 

商务合作,科技咨询,版权转让:向日葵,135—4855__4328,xiexiaokui#qq.com

TensorFlow DeepLab教程初稿-tensorflow gpu安装教程的更多相关文章

  1. win7&lpar;windows 7&rpar;系统下安装SQL2005&lpar;SQL Server 2005&rpar;图文教程&lpar; Win7 SQL Server2005 安装教程&rpar;

    win7(windows 7)系统下安装SQL2005(SQL Server 2005)图文教程 由于工作需要,今天要在电脑上安装SQL Server 2005.以往的项目都是使用Oracle,MS的 ...

  2. 【教程】Visual Studio2019安装教程

    Visual Studio正式版早就可以使用了,但是好多小伙伴还是不会用,今天小编就给大家带来了最新的安装教程和激活方法. Visual Studio 2019包含社区版(Community).专业版 ...

  3. VMware12安装虚拟机教程、Ubuntu16&period;04安装教程(包括vmware tools的安装)

    转自https://jingyan.baidu.com/article/c275f6ba07e269e33d756714.html 方法/步骤 1 虚拟机.Linux操作系统介绍及下载地址 虚拟机VM ...

  4. 开发环境配置:jdk8的详细安装教程&amp&semi;&amp&semi;tomact的详细安装教程&amp&semi;&amp&semi;java环境变量的配置&amp&semi;&amp&semi;tomcat启动总失败原因

    1.下载 链接: http://pan.baidu.com/s/1i57HZKx 密码: cnb4 2.详细安装过程 3.下载地址 链接: http://pan.baidu.com/s/1mi6VUp ...

  5. Smokeping安装教程

    Smokeping安装教程 #Smokeping2.6.8安装教程 #2016.3.6 改编v1.0 #Linux运维技术交流 347163978   环境 CentOS release 6.4 (F ...

  6. WordPaster&period;exe安装教程

      安装教程: Firefox控件安装教程 Chrome控件安装教程 Chrome 45+控件安装教程 相关问题: 提示Runtime Error错误 360拦截 Chrome启用npapi Fire ...

  7. 调研Android Studio开发环境的发展演变(附安装教程,多图)

    Android Studio(以下简称AS)第一次公开亮相是在2013年的谷歌I/O大会上,14年的大会上谷歌发布其试用测试版,如今AS已经历数次版本更新,功能十分强大.如(摘自百度百科Android ...

  8. Hadoop完全分布式安装教程

    一.软件版本 Hadoop版本号:hadoop-2.6.0.tar: VMWare版本号:VMware-workstation-full-11.0.0-2305329 Ubuntu版本号:ubuntu ...

  9. Hadoop学习---Ubuntu中hadoop完全分布式安装教程

    软件版本 Hadoop版本号:hadoop-2.6.0-cdh5.7.0: VMWare版本号:VMware 9或10 Linux系统:CentOS 6.4-6.5 或Ubuntu版本号:ubuntu ...

随机推荐

  1. 【跟着子迟品 underscore】JavaScript 中如何判断两个元素是否 &quot&semi;相同&quot&semi;

    Why underscore 最近开始看 underscore.js 源码,并将 underscore.js 源码解读 放在了我的 2016 计划中. 阅读一些著名框架类库的源码,就好像和一个个大师对 ...

  2. SwiftLint——Swift代码检查及自动格式化工具

    某软不给力,正在做的UWP项目停工了.官方说法是要等到RS2发布新的VOIP架构,再看看是不是给某软面子.虽然Beta用户中发出了几点愤怒的声音,但是木有用.有用的只能是某软的Skype for bu ...

  3. SQL中的循环、for循环、游标

    我们使用SQL语句处理数据时,可能会碰到一些需要循环遍历某个表并对其进行相应的操作(添加.修改.删除),这时我们就需要用到咱们在编程中常常用的for或foreach,但是在SQL中写循环往往显得那么吃 ...

  4. UVa 489 HangmanJudge --- 水题

    UVa 489 题目大意:计算机给定一个单词让你猜,你猜一个字母,若单词中存在你猜测的字母,则会显示出来,否则算出错, 你最多只能出错7次(第6次错还能继续猜,第7次错就算你失败),另注意猜一个已经猜 ...

  5. MongoDB&commat;入门一

    安装MongoDB自行搜索, 我这里提供GUI版本类似navicat. 1. 数据库层面 show dbs #查看服务器上的数据库  [local  0.000GB] use test  #切换到指定 ...

  6. ASP&period;NET Core Web 支付功能接入 微信-扫码支付篇

    这篇文章将介绍ASP.NET Core中使用 开源项目 Payment,实现接入微信-扫码支付及异步通知功能. 开发环境:Win 10 x64.VS2017 15.6.4..NET Core SDK ...

  7. 动画讲解TCP的3次握手,4次挥手

    https://mp.weixin.qq.com/s/TUBhH_lJe6M4KgAZO-rP2A TCP三次握手和四次挥手的问题在面试中是最为常见的考点之一.很多读者都知道三次和四次,但是如果问深入 ...

  8. 线上CPU100&percnt;排查

    生产服务器上部署了几个java程序,突然出现了CPU100%的异常告警,你如何定位出问题? 这个问题分为两版回答!高调版对不起,我是做研发的,这个问题在生产上是不可能遇见的!因为研发是不可能直接操作生 ...

  9. 海南医院帆软报表 最终版本SQL

    1. 挂号微信收入明细 -- WANTED-1283 门诊查询统计报表-挂号微信收入明细 select p.name as patientName, -- 患者姓名 p.birthday, -- 出生 ...

  10. java 获取时间戳的三种方式

      java 获取时间戳的三种方式 CreationTime--2018年7月13日16点29分 Author:Marydon 1.实现方式 方式一:推荐使用 System.currentTimeMi ...