- Create a directory called
- Install Sourcetree
- Clone this repo (
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
- 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
Window ==> Preferences ==> PyDev ==> Interpreter - PythonSelect
Qucik auto-Configand it should find
Import Python Project into Eclipse (PyDev)
- Right click ==> New... ==> Project...
- PyDev ==> PyDev Project ==> Next
- Uncheck 'Use Default'
- Browse to project Directory
- Copypasta Project Name
To get Python to run from the command line, open up the command promt (type
This adds all the correct paths to the $PATH.
Test Python in Eclipse
hellopy.py==> Run As ==> Python Run
if __name__ == '__main__': print('Hello World')
CUDA and CUDNN
- 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
python -m pip install --upgrade pip
pip install --upgrade tensorflow-gpu
Test TensorFlow in Eclipse
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
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.
Force to run on CPU (disable GPU)
- Open up
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())
CPU vs GPU
Running on the CPU took 25 minutes, while running on the GPU took 14 minutes.
- Open up the Git command prompt (not
cd ~/path_to/workspace_tf python models/tutorials/image/cifar10/cifar10_train.py
In a different console window:
Open the link it gives you in browser to view tensorboard.
After training and monitoring on tensorboard:
Results on Windows CPU vs GPU
|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!