Installing TensorFlow with conda Explained
In this post, we will learn to install TensorFlow with conda
Take the following steps to install TensorFlow in an Anaconda environment:
If you installed through Anaconda, activate your Anaconda environment.
Invoke python from your shell as follows:
$ python
Enter the following short program inside the python interactive shell:
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
If the system outputs the following, then you are ready to begin writing TensorFlow programs:
Hello, TensorFlow!
For this setup, we first need to understand what is conda and why we use it.
What is conda
conda is an open source package management system which creates and manages different environment and packages.
Why we use conda
By using conda we can create different instances of the same compiler. Like we can create different versions of python with different packages so that the packages do not interfere with each other.
Installing with Anaconda
1. Follow the instructions on the Anaconda download site to download and install Anaconda. Launch anaconda terminal.
2. Create a conda environment named tensorflow by invoking the following command:
C:> conda create -n tensorflow pip python=3.5
3. Activate the conda environment by issuing the following command:
C:> activate tensorflow
(tensorflow)C:> # Your prompt should change
(tensorflow)C:> # Your prompt should change
4. Issue the appropriate command to install TensorFlow inside your conda environment.
To install the CPU-only version of TensorFlow, enter the following command:
(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow
To install the GPU version of TensorFlow, enter the following command (on a single line):
(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow-gpu
To install the CPU-only version of TensorFlow, enter the following command:
(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow
To install the GPU version of TensorFlow, enter the following command (on a single line):
(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow-gpu
Validate your installation
Start a terminal.If you installed through Anaconda, activate your Anaconda environment.
Invoke python from your shell as follows:
$ python
Enter the following short program inside the python interactive shell:
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
If the system outputs the following, then you are ready to begin writing TensorFlow programs:
Hello, TensorFlow!
Now a python version exists named TensorFlow in your local Anaconda folder which contains Tensorflow libraries.
For getting its location type
C:>conda info –envs
Output would be like
C:/Users/user/AppData/Local/conda/conda/envs/tensorflow
Using this environment in sypder
Launch Spyder
1. Go to Tools>Preference>python interpreter
2. Select use the following interpreter
3. Type the path of the interpreter
E.g. C:/Users/user/AppData/Local/conda/conda/envs/tensorflow/python.exe
you also have to add support for spyder in your environment
launch console
>activate tenserflow
>install ipykernel cloudpickle
All set Happy coding!
Comments
Post a Comment