|
(Updated as of 06/20/2018)
Previously, it was possible to run TensorFlow within a Windows environment by using a Docker container. There were many downsides to this method—the most significant of which was lack of GPU support. With GPUs often resulting in more than a 10x performance increase over CPUs, it's no wonder that people were interested in running TensorFlow natively with full GPU support. As of December 2016, this is now possible. And the best part is, it only takes a minute to setup:
1) Prerequisites: cuda + cudnn (make sure cudnn components are extracted to the right places)
2) configure virtual python environment: conda create --name tensorflow-gpu python=3.5
(note that TensorFlow is only supported by python 3.5 in windows)
(to activate this environment: conda activate tensorflow-gpu; to deactivate it is to use: conda deactivate tensorflow-gpu)
3) activate tensorflow-gpu
4) pip install tensorflow-gpu
(pip install --ignore-installed --upgrade tensorflow-gpu)
Note tensorflow-gpu versions (as of 06/21/2018) (https://www.tensorflow.org/versions/) and their compatibility with cuda (https://developer.nvidia.com/cuda-toolkit-archive):
Versions: 0.12.0rc0, 0.12.0rc1, 0.12.0, 0.12.1, 1.0.0, 1.0.1, 1.1.0rc0, 1.1.0rc1, 1.1.0rc2, 1.1.0, 1.2.0rc0, 1.2.0rc1, 1.2.0rc2, 1.2.0, 1.2.1, 1.3.0rc0, 1.3.0rc1, 1.3.0rc2, 1.3.0, 1.4.0rc0, 1.4.0rc1, 1.4.0, 1.5.0rc0, 1.5.0rc1, 1.5.0, 1.5.1, 1.6.0rc0, 1.6.0rc1, 1.6.0, 1.7.0rc0, 1.7.0rc1, 1.7.0, 1.7.1, 1.8.0rc0, 1.8.0rc1, 1.8.0, 1.9.0rc0, 1.9.0rc1
The latest tensorflow-gpu 1.9 still ask for cuda9.0
https://github.com/tensorflow/tensorflow/issues/20865
5) test installation and gpu:
https://www.tensorflow.org/install/install_windows
https://www.tensorflow.org/tutorials/using_gpu
python #anaconda prompt
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
a = tf.constant(10)
b = tf.constant(32)
print(sess.run(a + b))
6) run mnist_deep.py for a cnn test #https://www.tensorflow.org/get_started/mnist/pros
The other way to run tensorflow is to install anaconda3 seperately or within the 'envs' subfolder of the anaconda 2, and then install tensorflow with pip installation as described above.
7) enable tensorflow as the backend of keras (https://keras.io/backend/)
modify the keras jason file:
"image_data_format": "channels_last"
"backend": "tensorflow"
8) import keras
C:\Users\YL\Anaconda2\envs\py35\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Using TensorFlow backend.
Sources:
https://www.tensorflow.org/versions/r0.12/get_started/os_setup#pip_installation_on_windows
https://www.tensorflow.org/install/install_windows#CommonInstallationProblems
https://github.com/jeffheaton/t81_558_deep_learning
http://blog.csdn.net/zcf1784266476/article/details/70158272
http://research.wmz.ninja/articles/2017/01/configuring-gpu-accelerated-keras-in-windows-10.html
http://lifeofajenni.com/2017/02/22/python-2x-and-3x-in-spyder/
https://conda.io/docs/user-guide/tasks/manage-python.html#installing-a-different-version-of-python
https://medium.com/@pushkarmandot/installing-tensorflow-theano-and-keras-in-spyder-84de7eb0f0df
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-9-22 15:19
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社