Setting Up Docker and TensorFlow for Mac OS X. Installing TensorFlow. ← Setting up Docker and TensorFlow for Windows 10 Professional Setting Up Docker.
Download and Setup You can install TensorFlow either from our provided binary packages or from the github source. Requirements The TensorFlow Python API supports Python 2.7 and Python 3.3+. The GPU version works best with Cuda Toolkit 7.5 and cuDNN v5.
Other versions are supported (Cuda toolkit = 7.0 and cuDNN = v3) only when installing from sources. Please see for details. For Mac OS X, please see. Overview We support different ways to install TensorFlow:.: Install TensorFlow on your machine, possibly upgrading previously installed Python packages. May impact existing Python programs on your machine.: Install TensorFlow in its own directory, not impacting any existing Python programs on your machine.: Install TensorFlow in its own environment for those running the Anaconda Python distribution. Does not impact existing Python programs on your machine.: Run TensorFlow in a Docker container isolated from all other programs on your machine.: Install TensorFlow by building a pip wheel that you then install using pip. If you are familiar with Pip, Virtualenv, Anaconda, or Docker, please feel free to adapt the instructions to your particular needs.
The names of the pip and Docker images are listed in the corresponding installation sections. If you encounter installation errors, see for some solutions. Pip Installation is a package management system used to install and manage software packages written in Python. The packages that will be installed or upgraded during the pip install are listed in the.
Install pip (or pip3 for python3) if it is not already installed: # Ubuntu/Linux 64-bit $ sudo apt - get install python - pip python - dev # Mac OS X $ sudo easyinstall pip $ sudo easyinstall - upgrade six Then, select the correct binary to install: # Ubuntu/Linux 64-bit, CPU only, Python 2.7 $ export TFBINARYURL = https:// storage. Com / tensorflow / linux / cpu / tensorflow - 0.10. 0 - cp27 - none - linuxx8664. Whl # Ubuntu/Linux 64-bit, GPU enabled, Python 2.7 # Requires CUDA toolkit 7.5 and CuDNN v5. For other versions, see 'Install from sources' below. $ export TFBINARYURL = https:// storage. Com / tensorflow / linux / gpu / tensorflow - 0.10.
0 - cp27 - none - linuxx8664. Whl # Mac OS X, CPU only, Python 2.7: $ export TFBINARYURL = https:// storage. Com / tensorflow / mac / cpu / tensorflow - 0.10. 0 - py2 - none - any. Whl # Mac OS X, GPU enabled, Python 2.7: $ export TFBINARYURL = https:// storage.
Com / tensorflow / mac / gpu / tensorflow - 0.10. 0 - py2 - none - any. Whl # Ubuntu/Linux 64-bit, CPU only, Python 3.4 $ export TFBINARYURL = https:// storage.
Com / tensorflow / linux / cpu / tensorflow - 0.10. 0 - cp34 - cp34m - linuxx8664.
Whl # Ubuntu/Linux 64-bit, GPU enabled, Python 3.4 # Requires CUDA toolkit 7.5 and CuDNN v5. For other versions, see 'Install from sources' below. $ export TFBINARYURL = https:// storage. Com / tensorflow / linux / gpu / tensorflow - 0.10. 0 - cp34 - cp34m - linuxx8664.
Whl # Ubuntu/Linux 64-bit, CPU only, Python 3.5 $ export TFBINARYURL = https:// storage. Com / tensorflow / linux / cpu / tensorflow - 0.10. 0 - cp35 - cp35m - linuxx8664. Whl # Ubuntu/Linux 64-bit, GPU enabled, Python 3.5 # Requires CUDA toolkit 7.5 and CuDNN v5. For other versions, see 'Install from sources' below. $ export TFBINARYURL = https:// storage. Com / tensorflow / linux / gpu / tensorflow - 0.10.
0 - cp35 - cp35m - linuxx8664. Whl # Mac OS X, CPU only, Python 3.4 or 3.5: $ export TFBINARYURL = https:// storage. Com / tensorflow / mac / cpu / tensorflow - 0.10. 0 - py3 - none - any.
Whl # Mac OS X, GPU enabled, Python 3.4 or 3.5: $ export TFBINARYURL = https:// storage. Com / tensorflow / mac / gpu / tensorflow - 0.10. 0 - py3 - none - any. Whl Install TensorFlow: # Python 2 $ sudo pip install - upgrade $TFBINARYURL # Python 3 $ sudo pip3 install - upgrade $TFBINARYURL NOTE: If you are upgrading from a previous installation of TensorFlow import tensorflow as tf hello = tf.
Constant ( 'Hello, TensorFlow!' ) sess = tf. Session print ( sess. Run ( hello )) Hello, TensorFlow! Constant ( 10 ) b = tf.
Constant ( 32 ) print ( sess. Run ( a + b )) 42 Run a TensorFlow demo model All TensorFlow packages, including the demo models, are installed in the Python library. The exact location of the Python library depends on your system, but is usually one of: / usr / local / lib / python2. 7 / dist - packages / tensorflow / usr / local / lib / python2. 7 / site - packages / tensorflow You can find out the directory with the following command (make sure to use the Python you installed TensorFlow to, for example, use python3 instead of python if you installed for Python 3): $ python - c 'import os; import inspect; import tensorflow; print(os.path.dirname(inspect.getfile(tensorflow)))' The simple demo model for classifying handwritten digits from the MNIST dataset is in the sub-directory models/image/mnist/convolutional.py.
![Install Install](/uploads/1/2/5/6/125625988/617977229.jpg)
You can run it from the command line as follows (make sure to use the Python you installed TensorFlow with): # Using 'python -m' to find the program in the python search path: $ python - m tensorflow. Convolutional Extracting data / train - images - idx3 - ubyte. Gz Extracting data / train - labels - idx1 - ubyte. Gz Extracting data / t10k - images - idx3 - ubyte.
Gz Extracting data / t10k - labels - idx1 - ubyte. # You can alternatively pass the path to the model program file to the python # interpreter (make sure to use the python distribution you installed # TensorFlow to, for example./python3.X/. For Python 3). $ python / usr / local / lib / python2. 7 / dist - packages / tensorflow / models / image / mnist / convolutional. Installing from sources When installing from source you will build a pip wheel that you then install using pip.
You'll need pip for that, so install it as described. Clone the TensorFlow repository $ git clone https:// github. Com / tensorflow / tensorflow Note that these instructions will install the latest master branch of tensorflow. If you want to install a specific branch (such as a release branch), pass -b to the git clone command and -recurse-submodules for r0.8 and earlier to fetch the protobuf library that TensorFlow depends on.
Prepare environment for Linux Install Bazel Follow instructions to install the dependencies for bazel. Then download the latest stable bazel version using the and run the installer as mentioned there: $ chmod + x PATHTOINSTALL. SH $./ PATHTOINSTALL. SH - user Remember to replace PATHTOINSTALL.SH with the location where you downloaded the installer. Finally, follow the instructions in that script to place bazel into your binary path.
Install other dependencies # For Python 2.7: $ sudo apt - get install python - numpy swig python - dev python - wheel # For Python 3.x: $ sudo apt - get install python3 - numpy swig python3 - dev python3 - wheel Optional: Install CUDA (GPUs on Linux) In order to build or run TensorFlow with GPU support, both NVIDIA's Cuda Toolkit (= 7.0) and cuDNN (= v3) need to be installed. TensorFlow GPU support requires having a GPU card with NVidia Compute Capability = 3.0. Supported cards include but are not limited to:. NVidia Titan. NVidia Titan X. NVidia K20.
NVidia K40 Check NVIDIA Compute Capability of your GPU card Download and install Cuda Toolkit Install version 7.5 if using our binary releases. Install the toolkit into e.g. /usr/local/cuda Download and install cuDNN Download cuDNN v5. Uncompress and copy the cuDNN files into the toolkit directory. Assuming the toolkit is installed in /usr/local/cuda, run the following commands (edited to reflect the cuDNN version you downloaded): tar xvzf cudnn - 7.5 - linux - x64 - v5.
![Tensorflow Tensorflow](/uploads/1/2/5/6/125625988/885571391.jpg)
Tgz sudo cp cuda / include / cudnn. H / usr / local / cuda / include sudo cp cuda / lib64 / libcudnn.
/ usr / local / cuda / lib64 sudo chmod a + r / usr / local / cuda / include / cudnn. H / usr / local / cuda / lib64 / libcudnn. Prepare environment for Mac OS X We recommend using to install the bazel and SWIG dependencies, and installing python dependencies using easyinstall or pip.
Of course you can also install Swig from source without using homebrew. In that case, be sure to install its dependency and not PCRE2.
Dependencies Follow instructions to install the dependencies for bazel. You can then use homebrew to install bazel and SWIG: $ brew install bazel swig You can install the python dependencies using easyinstall or pip.
This article is taken from the book, written by Quan Hua, Shams Ul Azeem and Saif Ahmed. This book will help tackle common commercial problems with Google’s 1.x library. Today, we shall explore the basics of getting started with, its installation and configuration process. The proliferation of large public datasets, inexpensive GPUs, and open-minded developer culture has revolutionized efforts in recent years. Training data, the lifeblood of machine learning, has become widely available and easily consumable in recent years.
Computing power has made the required horsepower available to small businesses and even individuals. The current decade is incredibly exciting for data scientists. Some of the top platforms used in the industry include Caffe, Theano, and Torch. While the underlying platforms are actively developed and openly shared, usage is limited largely to machine learning practitioners due to difficult installations, non-obvious configurations, and difficulty with productionizing solutions. TensorFlow has one of the easiest installations of any platform, bringing machine learning capabilities squarely into the realm of casual tinkerers and novice programmers. Meanwhile, high-performance features, such as—multiGPU support, make the platform exciting for experienced data scientists and industrial use as well. TensorFlow also provides a reimagined process and multiple user-friendly utilities, such as TensorBoard, to manage machine learning efforts.
Finally, the platform has significant backing and community support from the world’s largest machine learning powerhouse–Google. All this is before even considering the compelling underlying technical advantages, which we’ll dive into later. Installing TensorFlow TensorFlow conveniently offers several types of installation and operates on multiple operating systems. The basic installation is CPU-only, while more advanced installations unleash serious horsepower by pushing calculations onto the graphics card, or even to multiple graphics cards. We recommend starting with a basic CPU installation at first.
More complex GPU and CUDA installations will be discussed in Appendix, Advanced Installation. Even with just a basic CPU installation, TensorFlow offers multiple options, which are as follows:. A basic pip installation. A segregated installation via Virtualenv. A fully segregated container-based installation via Ubuntu installation Ubuntu is one of the best distributions for working with Tensorflow.
We highly recommend that you use an Ubuntu machine, especially if you want to work with GPU. We will do most of our work on the Ubuntu terminal. We will begin with installing pythonpip and python-dev via the following command: sudo apt-get install python-pip python-dev A successful installation will appear as follows: If you find missing packages, you can correct them via the following command: sudo apt-get update -fix-missing Then, you can continue the python and pip installation. We are now ready to install TensorFlow. The CPU installation is initiated via the following command: sudo pip install tensorflow A successful installation will appear as follows: macOS installation If you use Python, you will probably already have the Python package installer, pip. However, if not, you can easily install it using the easyinstall pip command. You’ll note that we actually executed sudo easyinstall pip—the sudo prefix was required because the installation requires administrative rights.
We will make the fair assumption that you already have the basic package installer, easyinstall, available; if not, you can install it from A successful installation will appear as shown in the following screenshot: Next, we will install the six package: sudo easyinstall -upgrade six A successful installation will appear as shown in the following screenshot: Surprisingly, those are the only two prerequisites for TensorFlow, and we can now install the core platform. We will use the pip package installer mentioned earlier and install TensorFlow directly from Google’s site. The most recent version at the time of writing this book is v1.3, but you should change this to the latest version you wish to use: sudo pip install tensorflow The pip installer will automatically gather all the other required dependencies. You will see each individual download and installation until the software is fully installed. A successful installation will appear as shown in the following screenshot: That’s it! If you were able to get to this point, you can start to train and run your first model.
Skip to Chapter 2, Your First Classifier, to train your first model. MacOS X users wishing to completely segregate their installation can use a VM instead, as described in the Windows installation. Windows installation As we mentioned earlier, TensorFlow with Python 2.7 does not function natively on Windows. In this section, we will guide you through installing TensorFlow with Python 3.5 and set up a VM with if you want to use TensorFlow with Python 2.7. First, we need to install Python 3.5.x or 3.6.x 64-bit from the following links: Make sure that you download the 64-bit version of Python where the name of the installation has amd64, such as python-3.6.2-amd64.exe. The Python 3.6.2 installation looks like this: We will select Add Python 3.6 to PATH and click Install Now.
The installation process will complete with the following screen: We will click the Disable path length limit and then click Close to finish the Python installation. Now, let’s open the Windows PowerShell application under the Windows menu.
We will install the CPU-only version of Tensorflow with the following command: pip3 install tensorflow. The result of the installation will look like this: Congratulations, you can now use TensorFlow on Windows with Python 3.5.x or 3.6.x support. In the next section, we will show you how to set up a VM to use TensorFlow with Python 2.7. However, you can skip to the Test installation section of Chapter 2, Your First Classifier, if you don’t need Python 2.7. Now, we will show you how to set up a VM with Linux to use TensorFlow with Python 2.7.
We recommend the free VirtualBox system available at The latest stable version at the time of writing is v5.0.14, available at the following URL: http:/ / download. Org/ virtualbox/ 5. 28/ VirtualBox- 5. 28- 117968- Win. Exe A successful installation will allow you to run the VM VirtualBox Manager dashboard, which looks like this: Testing the installation In this section, we will use TensorFlow to compute a simple math operation.
First, open your terminal on Linux/macOS or Windows PowerShell in Windows. Now, we need to run python to use TensorFlow with the following command: python Enter the following program in the Python shell: import tensorflow as tf a = tf.constant(1.0) b = tf.constant(2.0) c = a + b sess = tf.Session print(sess.run(c)) The result will look like the following screen where 3.0 is printed at the end: We covered TensorFlow installation on the three major operating systems, so that you are up and running with the platform. Windows users faced an extra challenge, as TensorFlow on Windows only supports Python 3.5.x or Python 3.6.x 64-bit version. However, even Windows users should now be up and running. Further get a detailed understanding of implementing Tensorflow with contextual examples in this.
If you liked this article, be sure to check out which will help you take up any challenge you may face while implementing TensorFlow 1.x in your machine learning environment.