SlideShare a Scribd company logo
1 of 65
Download to read offline
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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

More Related Content

What's hot

Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonNowell Strite
 
Python for Science and Engineering: a presentation to A*STAR and the Singapor...
Python for Science and Engineering: a presentation to A*STAR and the Singapor...Python for Science and Engineering: a presentation to A*STAR and the Singapor...
Python for Science and Engineering: a presentation to A*STAR and the Singapor...pythoncharmers
 
GDG Helwan Introduction to python
GDG Helwan Introduction to pythonGDG Helwan Introduction to python
GDG Helwan Introduction to pythonMohamed Hegazy
 
Introduction about Python by JanBask Training
Introduction about Python by JanBask TrainingIntroduction about Python by JanBask Training
Introduction about Python by JanBask TrainingJanBask Training
 
Introduction to python 3 2nd round
Introduction to python 3   2nd roundIntroduction to python 3   2nd round
Introduction to python 3 2nd roundYouhei Sakurai
 
Introduction to python 3
Introduction to python 3Introduction to python 3
Introduction to python 3Youhei Sakurai
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming LanguageLaxman Puri
 
Python Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & stylePython Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & styleKevlin Henney
 
Python Summer Internship
Python Summer InternshipPython Summer Internship
Python Summer InternshipAtul Kumar
 
web programming Unit VIII complete about python by Bhavsingh Maloth
web programming Unit VIII complete about python  by Bhavsingh Malothweb programming Unit VIII complete about python  by Bhavsingh Maloth
web programming Unit VIII complete about python by Bhavsingh MalothBhavsingh Maloth
 
Python Introduction | JNTUA | R19 | UNIT 1
Python Introduction | JNTUA | R19 | UNIT 1 Python Introduction | JNTUA | R19 | UNIT 1
Python Introduction | JNTUA | R19 | UNIT 1 FabMinds
 
Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...
Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...
Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...Edureka!
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1Kirti Verma
 
Why I Love Python
Why I Love PythonWhy I Love Python
Why I Love Pythondidip
 

What's hot (19)

Python ppt
Python pptPython ppt
Python ppt
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Python for Science and Engineering: a presentation to A*STAR and the Singapor...
Python for Science and Engineering: a presentation to A*STAR and the Singapor...Python for Science and Engineering: a presentation to A*STAR and the Singapor...
Python for Science and Engineering: a presentation to A*STAR and the Singapor...
 
GDG Helwan Introduction to python
GDG Helwan Introduction to pythonGDG Helwan Introduction to python
GDG Helwan Introduction to python
 
Introduction about Python by JanBask Training
Introduction about Python by JanBask TrainingIntroduction about Python by JanBask Training
Introduction about Python by JanBask Training
 
Introduction to python 3 2nd round
Introduction to python 3   2nd roundIntroduction to python 3   2nd round
Introduction to python 3 2nd round
 
Introduction to python 3
Introduction to python 3Introduction to python 3
Introduction to python 3
 
Beginning Python Programming
Beginning Python ProgrammingBeginning Python Programming
Beginning Python Programming
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
 
Python Tutorial for Beginner
Python Tutorial for BeginnerPython Tutorial for Beginner
Python Tutorial for Beginner
 
Python Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & stylePython Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & style
 
Python Summer Internship
Python Summer InternshipPython Summer Internship
Python Summer Internship
 
web programming Unit VIII complete about python by Bhavsingh Maloth
web programming Unit VIII complete about python  by Bhavsingh Malothweb programming Unit VIII complete about python  by Bhavsingh Maloth
web programming Unit VIII complete about python by Bhavsingh Maloth
 
Python Introduction | JNTUA | R19 | UNIT 1
Python Introduction | JNTUA | R19 | UNIT 1 Python Introduction | JNTUA | R19 | UNIT 1
Python Introduction | JNTUA | R19 | UNIT 1
 
Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...
Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...
Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Python Workshop
Python WorkshopPython Workshop
Python Workshop
 
Why I Love Python
Why I Love PythonWhy I Love Python
Why I Love Python
 

Viewers also liked

DIY Deep Learning with Caffe Workshop
DIY Deep Learning with Caffe WorkshopDIY Deep Learning with Caffe Workshop
DIY Deep Learning with Caffe Workshopodsc
 
Caffe framework tutorial
Caffe framework tutorialCaffe framework tutorial
Caffe framework tutorialPark Chunduck
 
Caffe framework tutorial2
Caffe framework tutorial2Caffe framework tutorial2
Caffe framework tutorial2Park Chunduck
 
Caffe - A deep learning framework (Ramin Fahimi)
Caffe - A deep learning framework (Ramin Fahimi)Caffe - A deep learning framework (Ramin Fahimi)
Caffe - A deep learning framework (Ramin Fahimi)irpycon
 
Classifier evaluation and comparison
Classifier evaluation and comparisonClassifier evaluation and comparison
Classifier evaluation and comparisonAnton Konushin
 
instruction of install Caffe on ubuntu
instruction of install Caffe on ubuntu instruction of install Caffe on ubuntu
instruction of install Caffe on ubuntu Pouya Ahv
 
Nurse schedule goal programming (Cyclical)
Nurse schedule goal programming (Cyclical)Nurse schedule goal programming (Cyclical)
Nurse schedule goal programming (Cyclical)Swapnil Soni
 
Face Recognition Based on Deep Learning (Yurii Pashchenko Technology Stream)
Face Recognition Based on Deep Learning (Yurii Pashchenko Technology Stream) Face Recognition Based on Deep Learning (Yurii Pashchenko Technology Stream)
Face Recognition Based on Deep Learning (Yurii Pashchenko Technology Stream) IT Arena
 
Computer Vision, Deep Learning, OpenCV
Computer Vision, Deep Learning, OpenCVComputer Vision, Deep Learning, OpenCV
Computer Vision, Deep Learning, OpenCVFarshid Pirahansiah
 

Viewers also liked (11)

DIY Deep Learning with Caffe Workshop
DIY Deep Learning with Caffe WorkshopDIY Deep Learning with Caffe Workshop
DIY Deep Learning with Caffe Workshop
 
Caffe framework tutorial
Caffe framework tutorialCaffe framework tutorial
Caffe framework tutorial
 
Caffe framework tutorial2
Caffe framework tutorial2Caffe framework tutorial2
Caffe framework tutorial2
 
Caffe - A deep learning framework (Ramin Fahimi)
Caffe - A deep learning framework (Ramin Fahimi)Caffe - A deep learning framework (Ramin Fahimi)
Caffe - A deep learning framework (Ramin Fahimi)
 
Classifier evaluation and comparison
Classifier evaluation and comparisonClassifier evaluation and comparison
Classifier evaluation and comparison
 
instruction of install Caffe on ubuntu
instruction of install Caffe on ubuntu instruction of install Caffe on ubuntu
instruction of install Caffe on ubuntu
 
Nurse schedule goal programming (Cyclical)
Nurse schedule goal programming (Cyclical)Nurse schedule goal programming (Cyclical)
Nurse schedule goal programming (Cyclical)
 
Face Recognition Based on Deep Learning (Yurii Pashchenko Technology Stream)
Face Recognition Based on Deep Learning (Yurii Pashchenko Technology Stream) Face Recognition Based on Deep Learning (Yurii Pashchenko Technology Stream)
Face Recognition Based on Deep Learning (Yurii Pashchenko Technology Stream)
 
Computer Vision, Deep Learning, OpenCV
Computer Vision, Deep Learning, OpenCVComputer Vision, Deep Learning, OpenCV
Computer Vision, Deep Learning, OpenCV
 
Object Recognition
Object RecognitionObject Recognition
Object Recognition
 
CUDA & CAFFE
CUDA & CAFFE CUDA & CAFFE
CUDA & CAFFE
 

Similar to Getting started with Linux and Python by Caffe

Similar to Getting started with Linux and Python by Caffe (20)

Python basics
Python basicsPython basics
Python basics
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
 
Python_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptxPython_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptx
 
Learn python
Learn pythonLearn python
Learn python
 
Python Course
Python CoursePython Course
Python Course
 
05 python.pdf
05 python.pdf05 python.pdf
05 python.pdf
 
The Python Book_ The ultimate guide to coding with Python ( PDFDrive ).pdf
The Python Book_ The ultimate guide to coding with Python ( PDFDrive ).pdfThe Python Book_ The ultimate guide to coding with Python ( PDFDrive ).pdf
The Python Book_ The ultimate guide to coding with Python ( PDFDrive ).pdf
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
 
python into.pptx
python into.pptxpython into.pptx
python into.pptx
 
Chapter - 1.pptx
Chapter - 1.pptxChapter - 1.pptx
Chapter - 1.pptx
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
Pythonfinalppt 170822121204
Pythonfinalppt 170822121204Pythonfinalppt 170822121204
Pythonfinalppt 170822121204
 
Pyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdfPyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdf
 
python-handbook.pdf
python-handbook.pdfpython-handbook.pdf
python-handbook.pdf
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Introduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdfIntroduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdf
 
Fundamentals of python
Fundamentals of pythonFundamentals of python
Fundamentals of python
 
python classes in thane
python classes in thanepython classes in thane
python classes in thane
 
Python Programming.pptx
Python Programming.pptxPython Programming.pptx
Python Programming.pptx
 

More from Lihang Li

Something about SSE and beyond
Something about SSE and beyondSomething about SSE and beyond
Something about SSE and beyondLihang Li
 
Some experiences and lessons learnt from hunting a job
Some experiences and lessons learnt from hunting a jobSome experiences and lessons learnt from hunting a job
Some experiences and lessons learnt from hunting a jobLihang Li
 
Point cloud mesh-investigation_report-lihang
Point cloud mesh-investigation_report-lihangPoint cloud mesh-investigation_report-lihang
Point cloud mesh-investigation_report-lihangLihang Li
 
Rtabmap investigation report-lihang
Rtabmap investigation report-lihangRtabmap investigation report-lihang
Rtabmap investigation report-lihangLihang Li
 
Rgbdslam and mapping_investigation_report-lihang
Rgbdslam and mapping_investigation_report-lihangRgbdslam and mapping_investigation_report-lihang
Rgbdslam and mapping_investigation_report-lihangLihang Li
 
DTAM: Dense Tracking and Mapping in Real-Time, Robot vision Group
DTAM: Dense Tracking and Mapping in Real-Time, Robot vision GroupDTAM: Dense Tracking and Mapping in Real-Time, Robot vision Group
DTAM: Dense Tracking and Mapping in Real-Time, Robot vision GroupLihang Li
 
2013新人见面会-中科院开源软件协会介绍-hustcalm
2013新人见面会-中科院开源软件协会介绍-hustcalm2013新人见面会-中科院开源软件协会介绍-hustcalm
2013新人见面会-中科院开源软件协会介绍-hustcalmLihang Li
 
像Hackers一样写博客-hustcalm
像Hackers一样写博客-hustcalm像Hackers一样写博客-hustcalm
像Hackers一样写博客-hustcalmLihang Li
 

More from Lihang Li (8)

Something about SSE and beyond
Something about SSE and beyondSomething about SSE and beyond
Something about SSE and beyond
 
Some experiences and lessons learnt from hunting a job
Some experiences and lessons learnt from hunting a jobSome experiences and lessons learnt from hunting a job
Some experiences and lessons learnt from hunting a job
 
Point cloud mesh-investigation_report-lihang
Point cloud mesh-investigation_report-lihangPoint cloud mesh-investigation_report-lihang
Point cloud mesh-investigation_report-lihang
 
Rtabmap investigation report-lihang
Rtabmap investigation report-lihangRtabmap investigation report-lihang
Rtabmap investigation report-lihang
 
Rgbdslam and mapping_investigation_report-lihang
Rgbdslam and mapping_investigation_report-lihangRgbdslam and mapping_investigation_report-lihang
Rgbdslam and mapping_investigation_report-lihang
 
DTAM: Dense Tracking and Mapping in Real-Time, Robot vision Group
DTAM: Dense Tracking and Mapping in Real-Time, Robot vision GroupDTAM: Dense Tracking and Mapping in Real-Time, Robot vision Group
DTAM: Dense Tracking and Mapping in Real-Time, Robot vision Group
 
2013新人见面会-中科院开源软件协会介绍-hustcalm
2013新人见面会-中科院开源软件协会介绍-hustcalm2013新人见面会-中科院开源软件协会介绍-hustcalm
2013新人见面会-中科院开源软件协会介绍-hustcalm
 
像Hackers一样写博客-hustcalm
像Hackers一样写博客-hustcalm像Hackers一样写博客-hustcalm
像Hackers一样写博客-hustcalm
 

Recently uploaded

High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...Call girls in Ahmedabad High profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 

Recently uploaded (20)

High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 

Getting started with Linux and Python by Caffe

  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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