I have installed Anaconda on Windows 64 bit. I have downloaded PyCharm for creating a project and in the terminal of PyCharm I have installed numpy
, scipy
To install TF on windows, follow the below-mentioned steps:
conda create --name tensorflow python=3.5
activate tensorflow
conda install jupyter
conda install scipy
pip install tensorflow-gpu
Use pip install tensorflow
in place of pip install tensorflow-gpu
, in case if you want to install CPU only version of TF.
Note: This installation has been tested with Anaconda Python 3.5 (64 bit). I have also tried the same installation steps with (a) Anaconda Python 3.6 (32 bit), (b) Anaconda Python 3.6 (64 bit), and (c) Anaconda Python 3.5 (32 bit), but all of them (i.e. (a), (b) and (c) ) failed.
Currently tensorflow has binaries only for Unix based OS i.e. Ubuntu Mac OS X - that's why no mention of Windows in setup docs.
There are long discussions on Github:
A SO answer - tensorflow — is it or will it (sometime soon) be compatible with a windows workflow?
Suggestion:
For now, on Windows, the easiest way to get started with TensorFlow would be to use Docker: http://tensorflow.org/get_started/os_setup.md#docker-based_installation
It should become easier to add Windows support when Bazel (the build system we are using) adds support for building on Windows, which is on the roadmap for Bazel 0.3. You can see the full Bazel roadmap here.
Or simply use a Linux VM (using VMPlayer), and the stated steps will setup it up for you.
For PyCharm - Once conda
environment will be created, you'll need to set the new interpretor (in conda environment) as the interpretor
to use in PyCharm
:
Now to use the conda interpreter from PyCharm go to file > settings > project > interpreter, select Add local in the project interpreter field (the little gear wheel) and browse the interpreter or past the path.
The default location - the environment lives under conda_root/envs/tensorflow
. The new python interpreter 'll be at conda_root/envs/tensorflow/bin/pythonX.X
, such that the site-packages
will be in conda_root/envs/tensorflow/lib/pythonX.X/site-packages
.
I have python 3.5 with anaconda. First I tried everything given above but it did not work for me on windows 10 64bit. So I simply tried:-
If you just have one version, then type in cmd:
C:/>conda install tensorflow
for multiple versions of python, type in cmd:
C:/>conda install tensorflow python=version(e.g.python=3.5)
It works, just give it a try.
After installation open ipython console and import tensorflow:
import tensorflow
If tensorflow installed properly then you are ready to go. Enjoy machine learning:-)
This worked for me:
conda create -n tensorflow python=3.5
activate tensorflow
conda install -c conda-forge tensorflow
Open Anaconda Navigator.
Change the dropdown of "Applications on" from "root" to "tensorflow"
see screenshot
Launch Spyder
Run a little code to validate you're good to go:
import tensorflow as tf
node1 = tf.constant(3, tf.float32)
node2 = tf.constant(4) # also tf.float32 implicitly
print(node1, node2)
or
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
The following command from inside your command window (and preferably, conda environment) will work provided you have an Nvidia graphics card.
conda install tensorflow-gpu
If you have anaconda version 2.7 installed on your windows, then go to anaconda prompt, type these two commands:
conda create -n tensorflow_env tensorflow
conda activate tensorflow_env
If it is activated, then the base will be replaced by tensorflow_env
i.e. now it will show (tensorflow_env) C:\Users>
You can now use import tensorflow as tf
for using tensorflow in your code.