Wednesday, February 1, 2017

Installing TensorFlow GPU on MacBook Pro (late 2013)

Note, installation works, but GPU TensorFlow does not.




CPU VERSION (tensorflow 0.12.1):




import tensorflow as tf
print("OUT: tensorflow imported")


OUT: tensorflow imported


from tensorflow.python.client import device_lib
def get_available_CPU_GPU():
    devices = device_lib.list_local_devices()
    #return [x.name for x in devices if x.device_type == 'CPU']
    return [x.name for x in devices ]
print(get_available_CPU_GPU())


['/cpu:0']


SAME CODE GPU VERSION (tensorflow-gpu 0.12.1 ):


OUT: tensorflow imported


print(get_available_CPU_GPU())

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
 in ()
----> 1 from tensorflow.python.client import device_lib
      2 
      3 def get_available_CPU_GPU():
      4     devices = device_lib.list_local_devices()
      5     #return [x.name for x in devices if x.device_type == 'CPU']

ImportError: No module named 'tensorflow.python'




I have logged the issue:
https://github.com/tensorflow/tensorflow/issues/7193


=====

Check for newest version:
TensorFlow get started page

I previously did export TF_BINARY_URL=..

$ echo $TF_BINARY_URL

https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.1-py3-none-any.whl

$ sudo  pip3 install --ignore-installed --upgrade $TF_BINARY_URL

The directory '/Users/ukilucas/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/ukilucas/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting tensorflow-gpu==0.12.1 from https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.1-py3-none-any.whl
  Downloading https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.1-py3-none-any.whl (83.6MB)
    100% |████████████████████████████████| 83.6MB 8.5kB/s 
Collecting numpy>=1.11.0 (from tensorflow-gpu==0.12.1)
  Downloading numpy-1.12.0-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.4MB)
    100% |████████████████████████████████| 4.4MB 165kB/s 
Collecting protobuf>=3.1.0 (from tensorflow-gpu==0.12.1)
  Downloading protobuf-3.2.0-py2.py3-none-any.whl (360kB)
    100% |████████████████████████████████| 368kB 1.2MB/s 
Collecting six>=1.10.0 (from tensorflow-gpu==0.12.1)
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting wheel>=0.26 (from tensorflow-gpu==0.12.1)
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |████████████████████████████████| 71kB 2.9MB/s 
Collecting setuptools (from protobuf>=3.1.0->tensorflow-gpu==0.12.1)
  Downloading setuptools-34.1.0-py2.py3-none-any.whl (389kB)
    100% |████████████████████████████████| 399kB 1.1MB/s 
Collecting appdirs>=1.4.0 (from setuptools->protobuf>=3.1.0->tensorflow-gpu==0.12.1)
  Downloading appdirs-1.4.0-py2.py3-none-any.whl
Collecting packaging>=16.8 (from setuptools->protobuf>=3.1.0->tensorflow-gpu==0.12.1)
  Downloading packaging-16.8-py2.py3-none-any.whl
Collecting pyparsing (from packaging>=16.8->setuptools->protobuf>=3.1.0->tensorflow-gpu==0.12.1)
  Downloading pyparsing-2.1.10-py2.py3-none-any.whl (56kB)
    100% |██████████████████    100% |██████████████████    100% |██████████████████    100% |████████████████████████████████| 61kB 2.0MB/s 
Installing collected packages: numpy, six, appdirs, pyparsing, packaging, setuptools, protobuf, wheel, tensorflow-gpu
Successfully installed appdirs-1.4.0 numpy-1.12.0 packaging-16.8 protobuf-3.2.0 pyparsing-2.1.10 setuptools-34.1.0 six-1.10.0 tensorflow-gpu-0.12.1 wheel-0.29.0




(tensorflow) $ conda list
# packages in environment at /Users/ukilucas/anaconda3/envs/tensorflow:
#
alabaster                 0.7.9                    py35_0  
appdirs                   1.4.0                    
appnope                   0.1.0                    py35_0  
appscript                 1.0.1                    py35_0  
numpy                     1.12.0                   
openssl                   1.0.2k                        0  
packaging                 16.8                     
pip                       9.0.1                    py35_1  
protobuf                  3.2.0                    
pyparsing                 2.1.10                   
python                    3.5.2                         0  
readline                  6.2                           2  
setuptools                27.2.0                   py35_0  
setuptools                34.1.0                   
six                       1.10.0                   
sqlite                    3.13.0                        0  
tensorflow-gpu            0.12.1                   
tk                        8.5.18                        0  
wheel                     0.29.0                   py35_0  
wheel                     0.29.0                   
xz                        5.2.2                         1  

zlib                      1.2.8                         3