- Create a directory called
workspace_tf
somewhere. - Install Sourcetree
- Clone this repo (
cd ~/path_to/workspace_tf
,git clone https://github.com/Knowm/HelloTensorFlow.git
) - Install Git-Gui (for command line stuff)
- Install Java8
- Install Python
- Install Eclipse
- Create a workspace pointing to
workspace_tf
. - Install PyDev in Eclipse.
Help ==> Install new Software
... Click onAdd…
thenPyDev
inName
andhttp://pydev.org/updates/
inLocation
. SelectPyDev
and click through the wizard. - Configure PyDev in Eclipse preferences to point to installed Python executable. Go to
Window ==> Preferences ==> PyDev ==> Interpreter - Python
SelectQucik auto-Config
and it should findpython
automatically.
- Right click ==> New... ==> Project...
- PyDev ==> PyDev Project ==> Next
- Uncheck 'Use Default'
- Browse to project Directory
- Copypasta Project Name
- Next
To get Python to run from the command line, open up the command promt (type cmd
), then:
c:/Path/to/AppData/Local/Programs/Python/Python36/Tools/scripts/win_add2path.py
This adds all the correct paths to the $PATH.
- Right-click
hellopy.py
==> Run As ==> Python Run
if __name__ == '__main__':
print('Hello World')
Hello World
- CUDA installation guide
- Nvidia recommends installing Visual Studio so why not? Will come in handy later if developing GPU code.
The official Tensorflow 1.4 builds require CUDA 8 and CuDNN 6, so don't install the latest and greatest.
- Download and install Cuda 8 Toolkit (Do the base install and the patch afterwards)
- Download CuDNN 6 Toolkit (requires nvidia developer account)
- Follow install [instructions] 1-3 (http://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html) (adapt for CUDA 8 and CuDNN 6) Follow additional instructions later for CuDNN dev, but not needed for TF.
- Open up the command promt (type
cmd
) python -m pip install --upgrade pip
pip install --upgrade tensorflow-gpu
- Right-click
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 08:56:23.787312: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2017-11-17 08:56:23.982426: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:1030] Found device 0 with properties:
name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.8225
pciBusID: 0000:01:00.0
totalMemory: 8.00GiB freeMemory: 6.66GiB
2017-11-17 08:56:23.982655: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0, compute capability: 6.1)
b'Hello, World'
- Open up the Git command prompt (not
cmd
!)
cd ~/path_to/workspace_tf
git clone https://github.com/tensorflow/models.git
python 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.
- Open up
models/tutorials/image/mnist/convolutional.py
. - Add...
import os
os.environ["CUDA_VISIBLE_DEVICES"]="-1" # this disables the GPU and it will run on the CPU only, set to "0" for GPU
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
Running on the CPU took 25 minutes, while running on the GPU took 14 minutes.
- Open up the Git command prompt (not
cmd
!)
cd ~/path_to/workspace_tf
python models/tutorials/image/cifar10/cifar10_train.py
In a different console window:
tensorboard --logdir=/tmp/cifar10_train
Open the link it gives you in browser to view tensorboard.
After training and monitoring on tensorboard:
python models/tutorials/image/cifar10/cifar10_eval.py
Device | Info |
---|---|
CPU | Intel i7-7700K 4.20 GHz 8 core |
GPU | NVidia 1080 8GB |
RAM | Apple 32GB DDR4 3200 MHz |
Running 5000 steps on the CPU took 28 minutes, while running on the GPU took a little over a minute for a 19.7x performance increase!