
上QQ阅读APP看书,第一时间看更新
Installing TensorFlow
- Execute the following command to install tensorflow using conda:
conda install -c conda-forge tensorflow
The output of this command will fetch metadata and install a list of packages, as follows:
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment /home/ubuntu/miniconda2:
- The following new packages will also be installed:
bleach: 1.5.0-py27_0 conda-forge
funcsigs: 1.0.2-py_2 conda-forge
futures: 3.2.0-py27_0 conda-forge
html5lib: 0.9999999-py27_0 conda-forge
markdown: 2.6.9-py27_0 conda-forge
mock: 2.0.0-py27_0 conda-forge
pbr: 3.1.1-py27_0 conda-forge
protobuf: 3.5.0-py27_0 conda-forge
tensorboard: 0.4.0rc3-py27_0 conda-forge
tensorflow: 1.4.0-py27_0 conda-forge
webencodings: 0.5-py27_0 conda-forge
werkzeug: 0.12.2-py_1 conda-forge
- A higher-priority channel will supersede the following packages, as follows:
conda: 4.3.30-py27h6ae6dc7_0 --> 4.3.29-py27_0 conda-forge
conda-env: 2.6.0-h36134e3_1 --> 2.6.0-0 conda-forge
Proceed ([y]/n)? y
conda-env-2.6. 100% |#############################################################| Time: 0:00:00 1.67 MB/s
...
mock-2.0.0-py2 100% |#############################################################| Time: 0:00:00 26.00 MB/s
conda-4.3.29-p 100% |#############################################################| Time: 0:00:00 27.46 MB/s
- Once TensorFlow has been installed, let's test it with a simple program. Create a new file called hello_tf.py with the following command:
vi hello_tf.py
- Add the following code to this file and save the file:
import tensorflow as tf
hello = tf.constant('Greetings, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
- Execute the file created from the command line:
python hello_tf.py
The output will make sure the library has been successfully installed:
Greetings, TensorFlow!