Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Getting started with Linux and Python by Caffe

15,278 views

Published on

Introduction to Linux and Python and Building Caffe from scratch and deploy on Linux.

Published in: Engineering

Getting started with Linux and Python by Caffe

  1. 1. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Introduction to Linux and Python Building Caffe from scratch and deploy on Linux Lihang Li NLPR CASIA - Robot Vision Group January 20, 2015 Lihang Li NLPR Getting Started With Linux and Python By Caffe
  2. 2. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Outline 1 Goal 2 Linux Basics Open Source Hello World Recommended Books 3 Fundamentals of Python Why Python A Byte of Python Good References 4 Caffe Build Caffe From Scratch Play With Caffe Examples 5 Conclusion 6 What’s Next Lihang Li NLPR Getting Started With Linux and Python By Caffe
  3. 3. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next What’s in this talk? Linux Get familiar with basic Linux commands and tools. Python Able to read Caffe sample code and hack some simple Python code. Caffe Deploy Caffe on Linux by building from source code and learn the examples. Lihang Li NLPR Getting Started With Linux and Python By Caffe
  4. 4. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Open Source Hello World Recommended Books Outline 1 Goal 2 Linux Basics Open Source Hello World Recommended Books 3 Fundamentals of Python Why Python A Byte of Python Good References 4 Caffe Build Caffe From Scratch Play With Caffe Examples 5 Conclusion 6 What’s Next Lihang Li NLPR Getting Started With Linux and Python By Caffe
  5. 5. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Open Source Hello World Recommended Books Free Software What is Free Software? Free software means the users have the freedom to run, copy, distribute, study, change and improve the software. Free software is a matter of liberty, not price. To understand the concept, you should think of free as in free speech, not as in free beer. Lihang Li NLPR Getting Started With Linux and Python By Caffe
  6. 6. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Open Source Hello World Recommended Books Free Software Essential Freedoms The freedom to run the program as you wish, for any purpose (freedom 0). The freedom to study how the program works, and adapt it to your needs (freedom 1). Access to the source code is a precondition for this. The freedom to redistribute copies so you can help your neighbor (freedom 2). The freedom to improve the program, and release your improvements to the public, so that the whole community benefits (freedom 3). Access to the source code is a precondition for this. Lihang Li NLPR Getting Started With Linux and Python By Caffe
  7. 7. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Open Source Hello World Recommended Books GNU What is GNU? GNU is a Unix-like operating system. That means it is a collection of many programs: applications, libraries, developer tools, even games. The development of GNU, started in January 1984, is known as the GNU Project. Many of the programs in GNU are released under the auspices of the GNU Project; those we call GNU packages. The name GNU is a recursive acronym for GNU’s Not Unix. GNU is pronounced g’noo, as one syllable, like saying grew but replacing the r with n. Lihang Li NLPR Getting Started With Linux and Python By Caffe
  8. 8. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Open Source Hello World Recommended Books Linux Linux or GNU/Linux? The program in a Unix-like system that allocates machine resources and talk to the hardware is called the kernel. GNU is typically used with a kernel called Linux. This combination is the GNU/Linux operating system. GNU/Linux is used by millions, though many call it Linux by mistake. GNU’s own kernel, The Hurd, was started in 1990 (before Linux was started). Volunteers continue developing the Hurd because it is an interesting technical project. Without the GNU packages(gcc, make, etc), Linus would find it hard to start writing the Linux kernel. Lihang Li NLPR Getting Started With Linux and Python By Caffe
  9. 9. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Open Source Hello World Recommended Books Linux in a nutshell Linux Core Concepts Linux Kernel(Linux itself is an Operating System kernel) Linux Distro(Ubuntu, Fedora, SUSE, etc) Linux Shell(Bash, Zsh, Csh, sh, etc) Linux PackageManager(apt-get, yum, etc) Linux Toolchain(gcc, make, etc) Linux Commandline(cd, ls, cp, mv, rm, etc) Lihang Li NLPR Getting Started With Linux and Python By Caffe
  10. 10. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Open Source Hello World Recommended Books Basic Linux Commands File Operations ls, cd, pwd, cp, mv, rm, touch, etc Compression and Decompression tar, gzip, gunzip, unzip, bzip, etc Network ping, hostname, wget, curl, git, etc Development vim, gcc, make, ldd, gdb, export, source, etc Lihang Li NLPR Getting Started With Linux and Python By Caffe
  11. 11. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Open Source Hello World Recommended Books Hello Linux! #include <iostream > using namespace std; int main () { cout <<"Hello Linux!"<<endl; return 0; } Compile with g++ g++ hello linux.cpp -o hello linux && ./hello linux Build with make vim Makefile && make && ./hello linux Lihang Li NLPR Getting Started With Linux and Python By Caffe
  12. 12. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Open Source Hello World Recommended Books Linux Books Linux Pocket Guide Linux in a Nutshell Running Linux The Linux Command Line Advanced Linux Programming Advanced Programming in the Unix Environment(APUE) Lihang Li NLPR Getting Started With Linux and Python By Caffe
  13. 13. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Outline 1 Goal 2 Linux Basics Open Source Hello World Recommended Books 3 Fundamentals of Python Why Python A Byte of Python Good References 4 Caffe Build Caffe From Scratch Play With Caffe Examples 5 Conclusion 6 What’s Next Lihang Li NLPR Getting Started With Linux and Python By Caffe
  14. 14. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References What is Python? Python Python is a great object-oriented, interpreted, and interactive programming language, comparable to Perl, Ruby, Scheme, or Java. Python Features Open Source and cross-platform(Linux, MacOS, Windows...) Uses an elegant syntax, making the programs you write easier to read. Data types are strongly and dynamically typed. Automatic memory management. Lihang Li NLPR Getting Started With Linux and Python By Caffe
  15. 15. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Hello Python! #!/usr/bin/env python myString = "Hello Python!" print myString Run Python Interactive intepreter from the command line(Python or IPython) Running a script written in Python(python script name.py) Lihang Li NLPR Getting Started With Linux and Python By Caffe
  16. 16. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Python Basics - Variables and Assignments Python Variable counter = 0 # the integer miles = 1000.0 # the floating point name = ’Bob ’ # string couner = counter + 1 # an incremental statement for integer kilometers = 1.609* miles # floating point operation and assignment Lihang Li NLPR Getting Started With Linux and Python By Caffe
  17. 17. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Python Basics - Strings Python String pystr = ’PYTHON ’ iscool = ’is cool!’ pystr [0] # ’P’ pystr [2:5] # ’THO ’, from 2 to 4 iscool [:2] # ’is ’, from 0 to 1 pystr + iscool # ’PYTHON is cool!’ pystr *2 # ’PYTHONPYTHON ’ iscool [-1] # ’!’, counting backward Lihang Li NLPR Getting Started With Linux and Python By Caffe
  18. 18. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Python Basics - Lists and Tuples Python List alist = [1,2,3,4] alist # [1,2,3,4] alist [0] # [1] alist [2:] # [3,4] alist [:3] # [1,2,3] alist [1] = 5 alist # [1,5,3,4] Lihang Li NLPR Getting Started With Linux and Python By Caffe
  19. 19. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Python Basics - Lists and Tuples Python Tuple atuple = (’robots ’,77,93,’try ’) atuple # (’robots ’,77,93,’try ’) atuple [:3] # (’robots ’ ,77 ,93) atuple [1] = 5 # TypeError:’tuple ’ object dose not support item assignment Lihang Li NLPR Getting Started With Linux and Python By Caffe
  20. 20. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Python Basics - Dictionaries Python Dictionary prices = {’apple ’: 0.40, ’banana ’: 0.50} prices[’apple ’] # 0.40 prices.keys () # [’apple ’,’banana ’] prices[’orange ’] = 0.60 prices # {’apple ’: 0.40, ’banana ’: 0.50, ’orange ’: 0.60} Lihang Li NLPR Getting Started With Linux and Python By Caffe
  21. 21. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Python Basics - Conditional Statments Python If-Else if condition: # Code to run if condition true elif other_cond: # Code to run if other_cond and not condition else: # Code to run if not (condition and other_cond) # Python has a ternary operator x = a if condition else b Lihang Li NLPR Getting Started With Linux and Python By Caffe
  22. 22. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Python Basics - Loops Pyton For Loop for i in iterator: # Do something with i for i in iterator1: for j in iterator2: # Do something with i and j Lihang Li NLPR Getting Started With Linux and Python By Caffe
  23. 23. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Python Basics - Loops Python While Loop while some_condition : # Do something # Update condition Lihang Li NLPR Getting Started With Linux and Python By Caffe
  24. 24. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Python Basics - List comprehensions Python List Comprehensions # List comprehensions are syntactically dense method to build lists # Basic x = [item for item in iterable] # Can be combined with logicals x = [item for item in iterable if item >0] Lihang Li NLPR Getting Started With Linux and Python By Caffe
  25. 25. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Python Basics - Functions Python Functions def greet(name): print ’Hello ’, name greet(’Jack ’) greet(’Jill ’) greet(’Bob ’) Lihang Li NLPR Getting Started With Linux and Python By Caffe
  26. 26. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Python Basics - Functions Python Fuctions # Basic function () out = function(arg1 , arg2 , ...) # Return multiple outputs a,b,c = function () # Two input methods function(x,y) # In order(positional) function(file=’input ,csv ’, skiprows =10) # keyword Lihang Li NLPR Getting Started With Linux and Python By Caffe
  27. 27. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Python Basics - I/O Python Openning Files # indent your Python code to put into an email import glob # glob supports Unix style pathname extensions python_files = glob.glob (’*.py ’) for file_name in sorted(python_files): print ’ ------’ + file_name with open(file_name) as f: for line in f: print ’ ’ + line.rstrip () print Lihang Li NLPR Getting Started With Linux and Python By Caffe
  28. 28. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Python Basics - Packages and Modules Python Modules and Packages Modules in Python are simply Python files with the .py extension, which implement a set of functions. Modules are imported from other modules using the import command. Packages are namespaces which contain multiple packages and modules themselves. They are simply directories, which MUST contain a special file called init .py. Python Import Modules import numpy as np import caffe Lihang Li NLPR Getting Started With Linux and Python By Caffe
  29. 29. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Scientific Python SciPy SciPy(http://www.scipy.org/) is an open source library of scientific tools for Python. SciPy supplements the popular NumPy module, gathering a variety of high level science and engineering modules together as a single package. SciPy includes modules for linear algebra, optimization, integration, special functions, signal and image processing, statistics, genetic algorithms, ODE solvers, and others. NumPy Numerical Python(http://www.numpy.org/) adds a fast, compact, multidimensional array facility to Python. NumPy is the successor to both Numeric and Numarray. Lihang Li NLPR Getting Started With Linux and Python By Caffe
  30. 30. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Why Python A Byte of Python Good References Python Resources Links https://www.python.org/ https://wiki.python.org/ https://docs.python.org/ https://docs.python.org/2/tutorial/ Books A Byte of Python See also: https://wiki.python.org/moin/IntroductoryBooks Lihang Li NLPR Getting Started With Linux and Python By Caffe
  31. 31. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Outline 1 Goal 2 Linux Basics Open Source Hello World Recommended Books 3 Fundamentals of Python Why Python A Byte of Python Good References 4 Caffe Build Caffe From Scratch Play With Caffe Examples 5 Conclusion 6 What’s Next Lihang Li NLPR Getting Started With Linux and Python By Caffe
  32. 32. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples What is Caffe? Caffe is a deep learning framework developed with cleanliness, readability, and speed in mind. It was created by Yangqing Jia during his PhD at UC Berkeley, and is in active development by the Berkeley Vision and Learning Center (BVLC) and by community contributors. Caffe is released under the BSD 2-Clause license. With Caffe, you can do whatever Deep Learning can do easily! Lihang Li NLPR Getting Started With Linux and Python By Caffe
  33. 33. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Why use Caffe? Clean architecture enables rapid deployment. Readable & modifiable implementation fosters active development. Speed makes Caffe perfect for industry use. Caffe can process over 40M images per day with a single NVIDIA K40 or Titan GPU*. Thats 5 ms/image in training, and 2 ms/image in test. We believe that Caffe is the fastest CNN implementation available. Community: Caffe already powers academic research projects, startup prototypes, and even large-scale industrial applications in vision, speech, and multimedia. There is an active discussion and support community on Github. Lihang Li NLPR Getting Started With Linux and Python By Caffe
  34. 34. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Caffe-Core Software Packages Caffe(http://caffe.berkeleyvision.org/) CUDA(https://developer.nvidia.com/) cuDNN(https://developer.nvidia.com/cuDNN) OpenBLAS(http://www.openblas.net/) OpenCV(http://opencv.org/) Boost(http://www.boost.org/) Lihang Li NLPR Getting Started With Linux and Python By Caffe
  35. 35. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Caffe-Other Dependencies protobuf(https://github.com/google/protobuf) google-glog(https://code.google.com/p/google-glog/) gflags(https://code.google.com/p/gflags/) snappy(https://github.com/google/snappy) leveldb(https://github.com/google/leveldb) lmdb(http://symas.com/mdb/) hdf5(http://www.hdfgroup.org/HDF5/) Lihang Li NLPR Getting Started With Linux and Python By Caffe
  36. 36. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Caffe-Build Tools CMake(http://www.cmake.org/) make(http://www.gnu.org/software/make/) Lihang Li NLPR Getting Started With Linux and Python By Caffe
  37. 37. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Build from Source vs. Package Manager Build from Source Much more customization and tuning Usually by invoking ./configure && make && make install A disaster when tons of dependencies arise Package Manager Install everything using just one simple command, such as sudo apt-get install meshlab Can’t be altered since the installed packages are pre-built Lihang Li NLPR Getting Started With Linux and Python By Caffe
  38. 38. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Get Caffe Source Code Get Caffe git clone https :// github.com/BVLC/caffe.git Lihang Li NLPR Getting Started With Linux and Python By Caffe
  39. 39. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Install OpenBLAS Install OpenBLAS git clone https :// github.com/xianyi/OpenBLAS.git make FC=gfortran NO_AFFINITY =1 USE_OPENMP =1 mkdir -p ~/ local/OpenBLAS make PREFIX=$HOME/local/OpenBLAS install Lihang Li NLPR Getting Started With Linux and Python By Caffe
  40. 40. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Install protobuf Install protobuf wget https :// protobuf.googlecode.com/files/protobuf -2.5.0. tar.gz tar zxvf protobuf -2.5.0. tar.gz cd protobuf -2.5.0 ./ configure --prefix=$HOME/local make make install Lihang Li NLPR Getting Started With Linux and Python By Caffe
  41. 41. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Install snappy Install snappy wget https:// snappy.googlecode.com/files/snappy -1.1.1. tar.gz tar zxvf snappy -1.1.1. tar.gz cd snappy -1.1.1 ./ configure --prefix=$HOME/local make make install Lihang Li NLPR Getting Started With Linux and Python By Caffe
  42. 42. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Install leveldb Install leveldb wget https:// leveldb.googlecode.com/files/leveldb -1.15.0. tar.gz tar zxvf leveldb -1.15.0. tar.gz cd leveldb -1.15.0 make cp -av libleveldb .* $HOME/local/lib/ cp -av include/leveldb $HOME/local/include/ Lihang Li NLPR Getting Started With Linux and Python By Caffe
  43. 43. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Install OpenCV Install OpenCV wget https:// github.com/Itseez/opencv/archive /2.4.8. tar.gz tar zxvf 2.4.8. tar.gz && cd opencv -2.4.8 mkdir release && cd release cmake -D CMAKE_BUILD_TYPE =RELEASE -D CMAKE_INSTALL_PREFIX =$HOME/local -D BUILD_opencv_gpu =OFF .. make && make install Lihang Li NLPR Getting Started With Linux and Python By Caffe
  44. 44. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Install Boost Install Boost wget http:// cznic.dl.sourceforge.net/project/boost/ boost /1.55.0/ boost_1_55_0.tar.gz ./ bootstrap.sh --prefix=$HOME/local ./b2 -j 32 ./b2 install Lihang Li NLPR Getting Started With Linux and Python By Caffe
  45. 45. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Install google-glog Install google-glog wget https://google -glog.googlecode.com/files/glog -0.3.3. tar.gz tar zxvf glog -0.3.3. tar.gz cd glog -0.3.3 ./ configure --prefix=$HOME/local make make install Lihang Li NLPR Getting Started With Linux and Python By Caffe
  46. 46. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Install gflags Install gflags git clone https:// code.google.com/p/gflags/ cd gflags mkdir build && cd build CXXFLAGS="-fPIC" cmake -D CMAKE_INSTALL_PREFIX =$HOME/ local .. make make install Lihang Li NLPR Getting Started With Linux and Python By Caffe
  47. 47. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Install lmdb Install lmdb git clone https:// gitorious.org/mdb/mdb.git cd mdb/libraries/liblmdb make make prefix=$HOME/local install Lihang Li NLPR Getting Started With Linux and Python By Caffe
  48. 48. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Install hdf5 Install hdf5 wget http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5 -1.8.14. tar.gz tar zxvf hdf5 -1.8.14. tar.gz && cd hdf5 -1.8.14 ./ configure --prefix=$HOME/local make && make check # run test suite. make install && make check -install # verify installation. Lihang Li NLPR Getting Started With Linux and Python By Caffe
  49. 49. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Install cuDNN Install cuDNN cp /data1/NLPRMNT/public/cudnn/lib64 /* ~/ local/lib cp /data1/NLPRMNT/public/cudnn/include /* ~/ local/ include Lihang Li NLPR Getting Started With Linux and Python By Caffe
  50. 50. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Modify Path Modify Path vim ~/. bashrc # Take CUDA for example export PATH =/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH =/usr/local/cuda/lib64: $LD_LIBRARY_PATH source ~/. bashrc Lihang Li NLPR Getting Started With Linux and Python By Caffe
  51. 51. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Build Caffe Build Caffe cp Makefile.config.example Makefile.config vim Makefile.config ============[ Makefile.config] USE_CUDNN := 1 CUDA_DIR := /usr/local/cuda INCLUDE_DIRS := /data1/NLPRMNT/xxx/local/include LIBRARY_DIRS := /data1/NLPRMNT/xxx/local/lib ============[ Makefile.config] make all -j8 make test -j8 Lihang Li NLPR Getting Started With Linux and Python By Caffe
  52. 52. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Caffe Usage Interfaces Caffe has command line, Python, and MATLAB interfaces for day-to-day usage, interfacing with research code, and rapid prototyping. While Caffe is a C++ library at heart and it exposes a modular interface for development, not every occasion calls for custom compilation. The cmdcaffe, pycaffe, and matcaffe interfaces are here for you. Lihang Li NLPR Getting Started With Linux and Python By Caffe
  53. 53. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Caffe Interface - cmdcaffe cmdcaffe The command line interface cmdcaffe is the caffe tool for model training, scoring, and diagnostics. Run caffe without any arguments for help. This tool and others are found in caffe/build/tools. Lihang Li NLPR Getting Started With Linux and Python By Caffe
  54. 54. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples cmdcaffe - Training caffe train learns models from scratch, resumes learning from saved snapshots, and fine-tunes models to new data and tasks. All training requires a solver configuration through the -solver solver.prototxt argument. Resuming requires the -snapshot model iter 1000.solverstate argument to load the solver snapshot. # train LeNet caffe train -solver examples/mnist/lenet_solver. prototxt # train on GPU 2 caffe train -solver examples/mnist/lenet_solver. prototxt -gpu 2 Lihang Li NLPR Getting Started With Linux and Python By Caffe
  55. 55. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples cmdcaffe - Testing caffe test scores models by running them in the test phase and reports the net output as its score. The net architecture must be properly defined to output an accuracy measure or loss as its output. The per-batch score is reported and then the grand average is reported last. # score the learned LeNet model on the validation set as defined in the model architeture lenet_train_test .prototxt caffe test -model examples/mnist/ lenet_train_test . prototxt -weights examples/mnist/ lenet_iter_10000 -gpu 0 -iterations 100 Lihang Li NLPR Getting Started With Linux and Python By Caffe
  56. 56. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples cmdcaffe - Benchmarking caffe time benchmarks model execution layer-by-layer through timing and synchronization. This is useful to check system performance and measure relative execution times for models. # time LeNet training on CPU for 10 iterations caffe time -model examples/mnist/ lenet_train_test . prototxt -iterations 10 # time LeNet training on GPU for the default 50 iterations caffe time -model examples/mnist/ lenet_train_test . prototxt -gpu 0 Lihang Li NLPR Getting Started With Linux and Python By Caffe
  57. 57. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples cmdcaffe - Diagnostics caffe device query reports GPU details for reference and checking device ordinals for running on a given device in multi-GPU machines. # query the first device caffe device_query -gpu 0 Lihang Li NLPR Getting Started With Linux and Python By Caffe
  58. 58. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Caffe Interface - pycaffe pycaffe The Python interface pycaffe is the caffe module and its scripts in caffe/python. import caffe to load models, do forward and backward, handle IO, visualize networks, and even instrument model solving. All model data, derivatives, and parameters are exposed for reading and writing. Compile pycaffe by make pycaffe. The module dir caffe/python/caffe should be installed in your PYTHONPATH for import caffe. Lihang Li NLPR Getting Started With Linux and Python By Caffe
  59. 59. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples pycaffe caffe.Net is the central interface for loading, configuring, and running models. caffe.Classsifier and caffe.Detector provide convenience interfaces for common tasks. caffe.SGDSolver exposes the solving interface. caffe.io handles input/output with preprocessing and protocol buffers. caffe.draw visualizes network architectures. Caffe blobs are exposed as numpy ndarrays for ease-of-use and efficiency. Lihang Li NLPR Getting Started With Linux and Python By Caffe
  60. 60. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Build Caffe From Scratch Play With Caffe Examples Caffe Interface - matcaffe The MATLAB interface matcaffe is the caffe mex and its helper m-files in caffe/matlab. Load models, do forward and backward, extract output and read-only model weights, and load the binaryproto format mean as a matrix. Compile matcaffe by make matcaffe. A MATLAB demo is in caffe/matlab/caffe/matcaffe demo.m Lihang Li NLPR Getting Started With Linux and Python By Caffe
  61. 61. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Outline 1 Goal 2 Linux Basics Open Source Hello World Recommended Books 3 Fundamentals of Python Why Python A Byte of Python Good References 4 Caffe Build Caffe From Scratch Play With Caffe Examples 5 Conclusion 6 What’s Next Lihang Li NLPR Getting Started With Linux and Python By Caffe
  62. 62. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Linux We have learned basic Linux commands and tools(such as wget, make) for building a software package from source. Python By learning basic Python grammars, the audience are expected to be able to read the source code of Caffe Python samples and do some simple hack. Caffe Through learning how to deploy Caffe on Linux by building from source code, people should find it comfortable to deploy other complicated software packages by reading the README or help file shipped with the packages. Lihang Li NLPR Getting Started With Linux and Python By Caffe
  63. 63. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Outline 1 Goal 2 Linux Basics Open Source Hello World Recommended Books 3 Fundamentals of Python Why Python A Byte of Python Good References 4 Caffe Build Caffe From Scratch Play With Caffe Examples 5 Conclusion 6 What’s Next Lihang Li NLPR Getting Started With Linux and Python By Caffe
  64. 64. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next Enjoy Caffe, Enjoy Open Source! Deep Learning Deploy Caffe on Linux by yourself Dive into Linux and Python by referencing great books Discuss with others and share experience with Caffe Use Caffe to tackle your Deep Learning problems Contribute your own source code to Caffe to make it better! Lihang Li NLPR Getting Started With Linux and Python By Caffe
  65. 65. Goal Linux Basics Fundamentals of Python Caffe Conclusion What’s Next The End Thank You & Have Fun! Lihang Li NLPR Getting Started With Linux and Python By Caffe

×