how to set up tensorflow

Published: 21 Sep 2017 Category: artificial intelligence

tensorflow - what it is

okay, no need to talk much about it as it was a famous open source artificial intelligence software invented by google.

tensorflow - how to setup

It’s really not good as in china we have been limited by the party so we can’t access some resources outside the big firewall, yes we can use VPN, so follow the install guide, and the way to install through Anaconda is the best way, luckily Anaconda was accessable even without VPN.

setup on windows 10

conda create -n tensorflow-gpu python=3.6.4
activate tensorflow-gpu
pip install tensorflow-gpu
git clone https://github.com/tensorflow/models.git

build on windows 10 README

# run from C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2017\Visual Studio Tools\VC x86_64 cmd
cd tensorflow\contrib\cmake
mkdir build
cd build
set PATH=C:\opt\cmake-3.11.1-win64-x64\bin;%PATH%
cmake .. -A x64 -DCMAKE_BUILD_TYPE=Release ^
  -DSWIG_EXECUTABLE=C:\opt\swigwin-3.0.12\swig.exe ^
  -DPYTHON_EXECUTABLE=C:/Anaconda3/envs/tensorflow-gpu/python.exe ^
  -DPYTHON_LIBRARIES=C:/Anaconda3/envs/tensorflow-gpu/libs/python36.lib ^
  -DPYTHON_INCLUDE_DIRS=C:/Anaconda3/envs/tensorflow-gpu/include ^
  -Dtensorflow_WIN_CPU_SIMD_OPTIONS=/arch:AVX2 ^
  -Dtensorflow_BUILD_SHARED_LIB=ON ^
  -DCUDA_HOST_COMPILER=cl.exe ^
  -Dtensorflow_ENABLE_GPU=ON ^
  -DCUDNN_HOME="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0"
MSBuild /p:Configuration=Release tf_python_build_pip_package.vcxproj
MSBuild /p:Configuration=Release ALL_BUILD.vcxproj

setup on Ubuntu 18.04

  • Run below commands to install Nvida GPU driver
ubuntu-drivers  devices
sudo ubuntu-drivers autoinstall

This is the simplest way

  • Reboot the system to load the graphical interface.

  • Install the cuda toolkit without the provide Nvida GPU driver, just install the cuda toolkit and samples

build on Ubuntu 18.04

Yes, I want to build out a C or C++ library so that I could build applicaiton could run on desktop computer or any other platform, I want to reseach about how to load a pb model and feed the input and then get the output.

bazel build --config=opt //tensorflow:libtensorflow.so
bazel build --config=opt //tensorflow:libtensorflow_cc.so

tensorflow - an example do object detection

This object detection model is really a good start point to have a try of tensorflow to see what it can do, it’s very good. Also there are many other models that could do really a lot of things, I am planing to try them one by one if possible.

For the tool protoc, if ubuntu just use apt-get to install the necessary version, if win, download it from the github. For ubuntu, we can build it from source code by below command.

wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz
tar xf protobuf-2.6.1.tar.gz && cd protobuf-2.6.1
./configure && make && make check && sudo make install

Here is a CSDN sample that use object detection model to process video.

reference

deep learning book octave CNN Neural Networks and Deep Learning tensorflow operations

comments powered by Disqus