If you are coming to OSX from Ubuntu, the installation of applications can go smoothly, as Apple intends, or leave you beyond the threshold of frustration, in a dismal state of frustration, rage, and despair. The instructions at the TensorFlow website are correct, if everything goes as planned. But as noted, “Since a native pip installation is not walled-off, the pip installation might interfere with or be influenced by other Python-based installations on your system,” for me, this became a real problem.

I tried pip, then virtualenv, then Anaconda only to find that none of these worked, for various reasons I won’t go into here. The key issue with pip was that the ‘Collecting …’ stalled, it would hang there, for minutes, even hours (as I waited, and waited, just to make certain). When I canceled the process (CTRL-C), I noted a lockfile in the process output.

It was not until my associate Iurii M. had time to assist me, that he discovered a work-around, using pip with the ‘–no-cache-dir’ extension in order to force it to bypass the locked file (which we never did locate). Then, the collection just worked, as it should, and for the most part, it was installed and running in roughly 30 minutes, including the time required to open an NVIDA developer account and obtain the CUDNN license.

So, here’s how the installation of TensorFlow on OSX goes …

  1. Install Homebrew
    $ brew update
    $ brew upgrade
    $ brew doctor
    $ brew install python

    * always run brew and pip from user session, not root

  2. Upgrade pip install:
    $ pip install -U pip
     
  3. Install TensorFlow
    * use pip with cach disabled (to keep terminal from stalling):

    $ pip install –no-cache-dir -I tensorflow-gpu

  4. Install CUDA

    $ brew install Caskroom/cask/cuda

  5. Install CUDNN (from NVIDIA)
    https://developer.nvidia.com/cudnn

    $ Download cuDNN v5 (May 27, 2016), for CUDA 8.0

  6. Unzip & Install
    1. select location for unzip
    2. move items proper location:
      mv -v lib/libcudnn* /usr/local/cuda/lib
      mv -v include/cudnn.h /usr/local/cuda/include

     

  7. Test TensforFlow
    $ python
    $ import tensor flow