TensorFlow was originally developed by researchers and engineers in the Google Brain Group (part of the Google Machine Intelligence Research Institute) for machine learning and deep neural networks, but the system’s versatility makes it widely usable in other computing fields. It is currently the most popular project on Github star.
Prior to this, I wrote a simple introduction to TensorFlow. At that time, I failed to build the environment, and later work reasons, so far shelved for a period of time. Today, finally, after various twists and turns on my Own Mac, after a variety of attempts, the perfect build success. Here to share it out, I hope to help you.
Anaconda based installation
Anaconda is a Python scientific computing environment that integrates many third-party scientific computing libraries. Anaconda uses Conda as its package management tool and has its own computing environment, similar to Virtualenv.
Like Virtualenv, Conda stores dependency packages in different places for different Python projects. Anaconda installed on TensorFlow does not overwrite previously installed Python packages.
- Installation Anaconda
- To establish a
conda
Computing environment - Activate the environment, use
conda
The installationTensorFlow
- After successful installation, use each time
TensorFlow
Need to be activatedconda
The environment
Installation Anaconda:
Refer to Anaconda’s download page for guidance
Establish environmental
Create a conda computing environment called TensorFlow:
# Python 2.7$conda create -n tensorflow python=2.7# Python 3.4$conda create -n tensorflow python=3.4Copy the code
The activation
Activate the TensorFlow environment, and then install TensorFlow using the PIPs in it. Use the –ignore-installed flag when using easy_install to prevent errors.
URL of the TensorFlow Python package
$ source activate tensorflow
(tensorflow)$ # Your prompt should change
# Ubuntu/Linux 64-bit, CPU only, Python 2.7:
(tensorflow)$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0rc0-cp27-none-linux_x86_64.whl
# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7. Requires CUDA toolkit 7.5 and CuDNN v4.
# For other versions, see "Install from sources" below.
(tensorflow)$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.8.0rc0-cp27-none-linux_x86_64.whl
# Mac OS X, CPU only:
(tensorflow)$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0rc0-py2-none-any.whl
Copy the code
For Python 3.x:
$ source activate tensorflow
(tensorflow)$ # Your prompt should change
# Ubuntu/Linux 64-bit, CPU only, Python 3.4:
(tensorflow)$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0rc0-cp34-cp34m-linux_x86_64.whl
# Ubuntu/Linux 64-bit, GPU enabled, Python 3.4. Requires CUDA toolkit 7.5 and CuDNN v4.
# For other versions, see "Install from sources" below.
(tensorflow)$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.8.0rc0-cp34-cp34m-linux_x86_64.whl
# Mac OS X, CPU only:
(tensorflow)$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0rc0-py3-none-any.whl
Copy the code
After the Conda environment is activated, you can test:
$ python
>>> import tensorflow as tf
>>> print(tf.__version__)
# 0.11.0 rc0
Copy the code
Turn on or off the environment
When you are not using TensorFlow, close the environment:
(tensorflow)$ source deactivate
$ # Your prompt should change back
Copy the code
Reactivate when used again:
$ source activate tensorflow
(tensorflow)$ # Your prompt should change.
# Run Python programs that use TensorFlow..# When you are done using TensorFlow, deactivate the environment.
(tensorflow)$ source deactivate
Copy the code
PyCharm configuration
** Correct Interpreter configuration for Project
methods
- Preferences
- Project Interpreter
- Click More
The appended drawings
- Open the Preferences
- Open the Project Interpreters
- Demo Running Result