Running TensorFlow with GPU support

 

The following are only supported for Windows 10+ & 64-bit Installation method, GPU: NVIDIA® GPU 1070.

 

 1. Confirm which TensorFlow is installed?

>> The installation time for CPU-only TensorFlow is 5~10 minutes.

>> TensorFlow on GPU runs faster and performs faster than on CPU, but requires NVIDIA® GPU to be installed. And need to install NVIDIA software:

  • CUDA® Toolkit 9.0 (additional CUDA environment variables %PATH%) and associated NVIDIA drivers.
  • cuDNN v7.0 (Append the directory of the cuDNN DLL to the %PATH%environment variable; the cuDNN version must match exactly: if it cannot be found cuDNN64_7.dll, TensorFlow will not load. To use a different version of cuDNN, it must be built from source).
  • GPU card (CUDA compute capability 3.0+).

2. How to install TensorFlow?

>>Native "pip" (native pip does not run in an isolated container, so it will interfere with other Pythons in the system, I installed it by configuring the pip environment variable in the Python environment of VS 2017).

Please use python 3.5.x or above to install TensorFlow.

 

C:\> pip3 install --upgrade tensorflow
//Install the GPU version of TensorFlow
C:\> pip3 install --upgrade tensorflow-gpu

 

>>Anaconda (use conda to create a virtual environment, and use the pip install command to install inside Anaconda. Tensorflow does not officially support, test, and maintain cona packages, which is risky).

Install Anaconda .

 

//Create a conda environment named tensorflow
C:> conda create -n tensorflow pip python=3.5
//Activate the conda environment
C:> activate tensorflow
 (tensorflow)C:>  # Your prompt should change
//Install CPU-only TensorFlow in the conda environment
(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow 
//Install the GPU version of TensorFlow
(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow-gpu 

 

3. Verify the installation

 

$ python

>>>import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>>print(sess.run(hello))
Output:Hello, TensorFlow! Successfully done.

 

Stack Overflow installation error messages and links:

1、41007279

[...\stream_executor\dso_loader.cc] Couldn't open CUDA library nvcuda.dll

2、41007279

[...\stream_executor\cuda\cuda_dnn.cc] Unable to load cuDNN DSO

3、42006320

ImportError: Traceback (most recent call last):
File "...\tensorflow\core\framework\graph_pb2.py", line 6, in
from google.protobuf import descriptor as _descriptor
ImportError: cannot import name 'descriptor'

4、42011070

No module named "pywrap_tensorflow

5、42217532

OpKernel ('op: "BestSplits" device_type: "CPU"') for unknown op: BestSplits

6、43134753

The TensorFlow library wasn't compiled to use SSE instructions

7、38896424

Could not find a version that satisfies the requirement tensorflow

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 分割线 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 

 

Supplement: Install TensorFlow on MacOS X

 

Because it is built on a personal Mac, Python 2.7.10 is used here, without GPU support, please use super permissions.

 

1. Use easy_install to install the package management tool pip under python.

 

$ sudo easy_install pip
$ pip --version

pip 10.0.1 from /Library/Python/2.7/site-packages/pip-10.0.1-py2.7.egg/pip (python 2.7)

2. Install the compatibility module six (Six is ​​a Python 2 and 3 compatibility library) that is compatible with Python2 and Python3.

 

 

$ sudo easy_install --upgrade six
Password:
Searching for six
Reading https://pypi.python.org/simple/six/
Best match: six 1.11.0
Processing six-1.11.0-py2.7.egg
Removing six 1.4.1 from easy-install.pth file
six 1.11.0 is already the active version in easy-install.pth

Using /Library/Python/2.7/site-packages/six-1.11.0-py2.7.egg
Processing dependencies for six
Finished processing dependencies for six
 

 

3. Install the TensorFlow package.

 

$ sudo pip install -ignore-packages six https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.10.0-py2-none-any.whl

Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='storage.googleapis.com', port=443): Max retries exceeded with url: /tensorflow/mac/cpu/tensorflow-0.10.0-py2-none-any.whl (Caused by ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x108d43050>, 'Connection to storage.googleapis.com timed out. (connect timeout=15)'))

Execute the following command after downloading tensorflow-0.10.0-py2-none-any.whl.

$ sudo pip install -ignore-packages six /Users/Downloads/tensorflow-0.10.0-py2-none-any.whl

 Here the error "Could not find a version that satisfies the requirement numpy>=1.10.1 (from tensorflow==0.10.0) (from versions: ) No matching distribution found for numpy>=1.10.1 (from tensorflow== 0.10.0)". Download  tensorflow1.7.0  version whl here.

 

 

4. Use easy_install to install the package numpy under python (support for multi-dimensional array objects, matrix operation math function library).

 

$ sudo easy_install numpy
 

 

5. Introduce the TensorFlow module into Python and run the test.

 

$ python
Python 2.7.10 (default, Oct  6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
dyld: warning, LC_RPATH $ORIGIN/../../_solib_darwin_x86_64/_U_S_Stensorflow_Spython_C_Upywrap_Utensorflow_Uinternal.so___Utensorflow in /Library/Python/2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so being ignored in restricted program because it is a relative path
>>> sess = tf.Session()
2018-04-26 00:47:30.723802: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
>>> a = tf.constant(2)
>>> 7 = tf.constant(7)
  File "<stdin>", line 1
SyntaxError: can't assign to literal
>>> b = tf.constant(7)
>>> print(sess.run(a+b))
9
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326069280&siteId=291194637