- Create a directory called
- Install Sourcetree (optional)
- Install Homebrew
- Clone this repo (
git clone https://github.com/Knowm/HelloTensorFlow.git)
brew cask install java
brew install python3
brew cask install eclipse-cppor
brew cask reinstall eclipse-cpp
PyDev in Eclipse
- Create an eclipse workspace that will be used to import
- Install PyDev in Eclipse.
Help ==> Install new Software... Click on
PyDevand click through the wizard.
- Configure PyDev in Eclipse preferences to point to installed Python executable. Go to
Eclipse ==> Preferences ==> PyDev ==> Interpreter - PythonSelect
Import Python Project into Eclipse (PyDev)
- Right click ==> New... ==> Project...
- PyDev ==> PyDev Project ==> Next
- Uncheck 'Use Default'
- Browse to project Directory
- Type 'HelloTensorFlow' for Project Name
- Click 'Finish'
Test Python in Eclipse
src/hellopy.py ==> Run As ==> Python Run
if __name__ == '__main__': print('Hello World')
pip3 install --upgrade tensorflow
note: If pip3 has not been installed after executing
brew install python3, run:
brew postinstall python3
Test TensorFlow in Eclipse
src/hellotf.py==> Run As ==> Python Run
# https://mubaris.com/2017-10-21/tensorflow-101 # Import TensorFlow import tensorflow as tf # Define Constant output = tf.constant("Hello, World") # To print the value of constant you need to start a session. sess = tf.Session() # Print print(sess.run(output)) # Close the session sess.close()
2017-11-17 10:33:55.587159: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2017-11-17 10:33:55.587179: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2017-11-17 10:33:55.587188: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2017-11-17 10:33:55.587192: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. b'Hello, World'
Some Possible Issues
AttributeError: module 'enum' has no attribute 'IntFlag'==> run
pip3 uninstall enum34
RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6==> Just ignore the warning
Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA==> You need to compile TF yourself with the appropriate flags to leverage advanced CPU instructions. Just ignore.
cd ~/path_to/workspace_tf git clone https://github.com/tensorflow/models.git python3 models/tutorials/image/mnist/convolutional.py
Alternatively, import the models project into Eclipse as described above for HelloTensorFlow, right-click
tutorials/image/mnist/convolutional.py ==> Run As ==> Python Run.
cd ~/path_to/workspace_tf python3 models/tutorials/image/cifar10/cifar10_train.py
In a different console window:
Open http://localhost:6006 in browser to view tensorboard.
After training and monitoring on tensorboard:
cd ~/path_to/workspace_tf python3 models/tutorials/image/cifar10/cifar10_eval.py
should yield a consol output like:
2018-01-15 13:22:36.844078: precision @ 1 = 0.803 2018-01-15 13:27:47.173989: precision @ 1 = 0.803 2018-01-15 13:32:58.397531: precision @ 1 = 0.804 etc
Results on Mac (CPU only)
|CPU||Intel i5 2.9 GHz|
|RAM||Apple 8GB DDR3 1867 MHz 2 core|
Running 5000 steps on the CPU took 57 minutes.
If you receive an error like this:
ValueError: Failed to find file: /tmp/cifar10_data/cifar-10-batches-bin/data_batch_1.bin
it may be due to a corrupted data file after canceling (ctrl+c) a previous run attempt. Delete the /tmp/cifar10_data file and start again. If you can't see the /tmp files, enable viewing of hidden files by:
defaults write com.apple.finder AppleShowAllFiles YES