SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
Numba:

A JIT Compiler for Scientific
Python
1
Stan Seibert
Continuum Analytics
January 22, 2015
Why Python?
• For many programs, the most important resource
is developer time.
• The best code is:
• Easy to read
• Easy to understand
• Easy to modify
• But sometimes execution speed does matter.

Then what do you do?
2
Achieving Performance in Python
When you need speed in Python the most important
things you can do are:
1. Use profiling to understand where your
program spends time.

(Most of your code is irrelevant. Only worry
about the parts that matter.)
2. Leverage NumPy and SciPy when working
with numerical code.
3. Take a look at Numba…
3
How can Numba help?
• Numba is an open source Just-In-Time compiler
for Python functions.
• From the types of the function arguments, Numba
can often generate a specialized, fast, machine code
implementation at runtime.
• Designed to work best with numerical code and
NumPy arrays.
• Uses the LLVM library as the compiler backend.
4
Numba Features
• Numba supports:
• Windows (XP and later), OS X (10.7 and later), and
Linux
• 32 and 64-bit x86 CPUs and NVIDIA GPUs
• Python 2 and 3
• NumPy versions 1.6 through 1.9
• It does not require a C/C++ compiler on the user’s system.
• Requires less than 70 MB to install.
• Does not replace the standard Python interpreter

(all of your existing Python libraries are still available)
5
Creating a Ufunc
• Numba is the best way to make new ufuncs for
working with NumPy arrays
6
Compiling a Function
• Sometimes you can’t create a simple or efficient
array expression or ufunc. Use Numba to work
with array elements directly.
• Example: Suppose you have a boolean grid and you
want to find the maximum number neighbors a
cell has in the grid:
1 1 1
1 1 1 1 1
1 1 1 1 2 1
1 1 1 1 3 2 1
2 2 1 1 2 1
2 2 2 2 2
1 1 1 1 1
1 1 1
Compiling a Function
Compiling a Function
• Very hard to express this calculation purely as
array operations (and even if you do, it is likely
unreadable to non-NumPy experts).
• Numba let’s you write out the loops, but avoid the
penalty for having to loop over individual elements
in the Python interpreter:
169x faster!
9
Different Modes of Compilation
• Numba automatically selects between two different
levels of optimization when compiling a function:
• “object mode”: supports nearly all of Python, but
generally cannot speed up code by a large factor

(exception: see next slide)
• “nopython mode”: supports a subset of Python,
but runs at C/C++/FORTRAN speeds
10
Loop-Lifting
• In object mode, Numba will attempt to extract
loops and compile them in nopython mode.
• Works great for functions that are bookended by
uncompilable code, but have a compilable core
loop.
• All happens automatically.
11
Loop-Lifting
object mode
object mode
nopython mode
12
Nopython Mode Features
• Standard control and looping structures: if, else, while, for, range
• NumPy arrays, int, float, complex, booleans, and tuples
• Almost all arithmetic, logical, and bitwise operators as well as
functions from the math and numpy modules
• Nearly all NumPy dtypes: int, float, complex, datetime64,
timedelta64
• Array element access (read and write)
• Array reduction functions: sum, prod, max, min, etc
• Calling other nopython mode compiled functions
• Calling ctypes or cffi-wrapped external functions
13
Compiling for the GPU
GPU functions are called differently, but it is still Python!
MacBook Pro w/ GTX 650M GPU
Advanced Use Cases
• Compile new functions based on user input.
• Great for inserting a user-provided math
expression into a larger algorithm, while still
achieving C speeds.
• Optimization (least squares, etc) libraries that can
recompile themselves to inline a specific objective
function right into the algorithm
• Multithreaded calculation without having to worry
about the global interpreter lock (GIL).
15
NumbaPro
• NumbaPro adds higher level features on top of
Numba:
• Create ufuncs that run multithreaded on the
CPU or on the GPU
• GPU linear algebra
• GPU FFTs
16
Conclusion
• Numba is a JIT compiler than understands Python!
• Achieve the same speeds as compiled languages for
numerical and array-processing code.
• Can be used to create advanced workflows where
user input drives compilation at runtime.
• Open source, available at:
http://numba.pydata.org/
• Or:
conda	
  install	
  numba
17

Weitere ähnliche Inhalte

Was ist angesagt?

A Sneak Peek of MLIR in TensorFlow
A Sneak Peek of MLIR in TensorFlowA Sneak Peek of MLIR in TensorFlow
A Sneak Peek of MLIR in TensorFlowKoan-Sin Tan
 
運用現場で常に隣り合わせの障害対応、IIJの出した答え
運用現場で常に隣り合わせの障害対応、IIJの出した答え運用現場で常に隣り合わせの障害対応、IIJの出した答え
運用現場で常に隣り合わせの障害対応、IIJの出した答えIIJ
 
不揮発メモリ(NVDIMM)とLinuxの対応動向について
不揮発メモリ(NVDIMM)とLinuxの対応動向について不揮発メモリ(NVDIMM)とLinuxの対応動向について
不揮発メモリ(NVDIMM)とLinuxの対応動向についてYasunori Goto
 
PyQtではじめるGUIプログラミング
PyQtではじめるGUIプログラミングPyQtではじめるGUIプログラミング
PyQtではじめるGUIプログラミングRansui Iso
 
プログラマがUnityでSTGを作った話
プログラマがUnityでSTGを作った話プログラマがUnityでSTGを作った話
プログラマがUnityでSTGを作った話MASA_T_O
 
Fiche TD sur les systèmes informatiques
Fiche TD sur les systèmes informatiquesFiche TD sur les systèmes informatiques
Fiche TD sur les systèmes informatiquesATPENSC-Group
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorLinaro
 
UniRx完全に理解した
UniRx完全に理解したUniRx完全に理解した
UniRx完全に理解したtorisoup
 
続・PFN のオンプレML基盤の取り組み / オンプレML基盤 on Kubernetes 〜PFN、ヤフー〜 #2
続・PFN のオンプレML基盤の取り組み / オンプレML基盤 on Kubernetes 〜PFN、ヤフー〜 #2続・PFN のオンプレML基盤の取り組み / オンプレML基盤 on Kubernetes 〜PFN、ヤフー〜 #2
続・PFN のオンプレML基盤の取り組み / オンプレML基盤 on Kubernetes 〜PFN、ヤフー〜 #2Preferred Networks
 
なぜディスクレスハイパーバイザに至ったのか / Why did we select to the diskless hypervisor? #builde...
なぜディスクレスハイパーバイザに至ったのか / Why did we select to the diskless hypervisor? #builde...なぜディスクレスハイパーバイザに至ったのか / Why did we select to the diskless hypervisor? #builde...
なぜディスクレスハイパーバイザに至ったのか / Why did we select to the diskless hypervisor? #builde...whywaita
 
apprenez-a-programmer-en-python.pdf
apprenez-a-programmer-en-python.pdfapprenez-a-programmer-en-python.pdf
apprenez-a-programmer-en-python.pdfAnonyme101
 
押し合い判定を作った話
押し合い判定を作った話押し合い判定を作った話
押し合い判定を作った話Shoichi Yasui
 
Slurmのジョブスケジューリングと実装
Slurmのジョブスケジューリングと実装Slurmのジョブスケジューリングと実装
Slurmのジョブスケジューリングと実装Ryuichi Sakamoto
 

Was ist angesagt? (20)

A Sneak Peek of MLIR in TensorFlow
A Sneak Peek of MLIR in TensorFlowA Sneak Peek of MLIR in TensorFlow
A Sneak Peek of MLIR in TensorFlow
 
運用現場で常に隣り合わせの障害対応、IIJの出した答え
運用現場で常に隣り合わせの障害対応、IIJの出した答え運用現場で常に隣り合わせの障害対応、IIJの出した答え
運用現場で常に隣り合わせの障害対応、IIJの出した答え
 
不揮発メモリ(NVDIMM)とLinuxの対応動向について
不揮発メモリ(NVDIMM)とLinuxの対応動向について不揮発メモリ(NVDIMM)とLinuxの対応動向について
不揮発メモリ(NVDIMM)とLinuxの対応動向について
 
Aio
AioAio
Aio
 
PyQtではじめるGUIプログラミング
PyQtではじめるGUIプログラミングPyQtではじめるGUIプログラミング
PyQtではじめるGUIプログラミング
 
プログラマがUnityでSTGを作った話
プログラマがUnityでSTGを作った話プログラマがUnityでSTGを作った話
プログラマがUnityでSTGを作った話
 
Fiche TD sur les systèmes informatiques
Fiche TD sur les systèmes informatiquesFiche TD sur les systèmes informatiques
Fiche TD sur les systèmes informatiques
 
MPIによる並列計算
MPIによる並列計算MPIによる並列計算
MPIによる並列計算
 
PYthon
PYthonPYthon
PYthon
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
 
Python
PythonPython
Python
 
UniRx完全に理解した
UniRx完全に理解したUniRx完全に理解した
UniRx完全に理解した
 
Exercice2
Exercice2Exercice2
Exercice2
 
続・PFN のオンプレML基盤の取り組み / オンプレML基盤 on Kubernetes 〜PFN、ヤフー〜 #2
続・PFN のオンプレML基盤の取り組み / オンプレML基盤 on Kubernetes 〜PFN、ヤフー〜 #2続・PFN のオンプレML基盤の取り組み / オンプレML基盤 on Kubernetes 〜PFN、ヤフー〜 #2
続・PFN のオンプレML基盤の取り組み / オンプレML基盤 on Kubernetes 〜PFN、ヤフー〜 #2
 
なぜディスクレスハイパーバイザに至ったのか / Why did we select to the diskless hypervisor? #builde...
なぜディスクレスハイパーバイザに至ったのか / Why did we select to the diskless hypervisor? #builde...なぜディスクレスハイパーバイザに至ったのか / Why did we select to the diskless hypervisor? #builde...
なぜディスクレスハイパーバイザに至ったのか / Why did we select to the diskless hypervisor? #builde...
 
Multiprocessing in python
Multiprocessing in pythonMultiprocessing in python
Multiprocessing in python
 
Python - the basics
Python - the basicsPython - the basics
Python - the basics
 
apprenez-a-programmer-en-python.pdf
apprenez-a-programmer-en-python.pdfapprenez-a-programmer-en-python.pdf
apprenez-a-programmer-en-python.pdf
 
押し合い判定を作った話
押し合い判定を作った話押し合い判定を作った話
押し合い判定を作った話
 
Slurmのジョブスケジューリングと実装
Slurmのジョブスケジューリングと実装Slurmのジョブスケジューリングと実装
Slurmのジョブスケジューリングと実装
 

Andere mochten auch

Scaling PyData Up and Out
Scaling PyData Up and OutScaling PyData Up and Out
Scaling PyData Up and OutTravis Oliphant
 
Numba: Flexible analytics written in Python with machine-code speeds and avo...
Numba:  Flexible analytics written in Python with machine-code speeds and avo...Numba:  Flexible analytics written in Python with machine-code speeds and avo...
Numba: Flexible analytics written in Python with machine-code speeds and avo...PyData
 
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...Intel® Software
 
Buzzwords Numba Presentation
Buzzwords Numba PresentationBuzzwords Numba Presentation
Buzzwords Numba Presentationkammeyer
 
Numba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPyNumba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPyTravis Oliphant
 

Andere mochten auch (7)

Scaling PyData Up and Out
Scaling PyData Up and OutScaling PyData Up and Out
Scaling PyData Up and Out
 
Scala.io
Scala.ioScala.io
Scala.io
 
PyData Paris 2015 - Track 3.3 Antoine Pitrou
PyData Paris 2015 - Track 3.3 Antoine PitrouPyData Paris 2015 - Track 3.3 Antoine Pitrou
PyData Paris 2015 - Track 3.3 Antoine Pitrou
 
Numba: Flexible analytics written in Python with machine-code speeds and avo...
Numba:  Flexible analytics written in Python with machine-code speeds and avo...Numba:  Flexible analytics written in Python with machine-code speeds and avo...
Numba: Flexible analytics written in Python with machine-code speeds and avo...
 
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
 
Buzzwords Numba Presentation
Buzzwords Numba PresentationBuzzwords Numba Presentation
Buzzwords Numba Presentation
 
Numba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPyNumba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPy
 

Ähnlich wie Numba Overview

Scale up and Scale Out Anaconda and PyData
Scale up and Scale Out Anaconda and PyDataScale up and Scale Out Anaconda and PyData
Scale up and Scale Out Anaconda and PyDataTravis Oliphant
 
SciPy 2019: How to Accelerate an Existing Codebase with Numba
SciPy 2019: How to Accelerate an Existing Codebase with NumbaSciPy 2019: How to Accelerate an Existing Codebase with Numba
SciPy 2019: How to Accelerate an Existing Codebase with Numbastan_seibert
 
Cooking a rabbit pie
Cooking a rabbit pieCooking a rabbit pie
Cooking a rabbit pieTomas Doran
 
Real time system_performance_mon
Real time system_performance_monReal time system_performance_mon
Real time system_performance_monTomas Doran
 
Want to write a book in Jupyter - here's how
Want to write a book in Jupyter - here's howWant to write a book in Jupyter - here's how
Want to write a book in Jupyter - here's howJim Arlow
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friendLuis Goldster
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friendFraboni Ec
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friendYoung Alista
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friendJames Wong
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friendHarry Potter
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friendTony Nguyen
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friendHoang Nguyen
 
Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Fwdays
 
Building SciPy kernels with Pythran
Building SciPy kernels with PythranBuilding SciPy kernels with Pythran
Building SciPy kernels with PythranRalf Gommers
 
Preparing Codes for Intel Knights Landing (KNL)
Preparing Codes for Intel Knights Landing (KNL)Preparing Codes for Intel Knights Landing (KNL)
Preparing Codes for Intel Knights Landing (KNL)AllineaSoftware
 

Ähnlich wie Numba Overview (20)

Scale up and Scale Out Anaconda and PyData
Scale up and Scale Out Anaconda and PyDataScale up and Scale Out Anaconda and PyData
Scale up and Scale Out Anaconda and PyData
 
SciPy 2019: How to Accelerate an Existing Codebase with Numba
SciPy 2019: How to Accelerate an Existing Codebase with NumbaSciPy 2019: How to Accelerate an Existing Codebase with Numba
SciPy 2019: How to Accelerate an Existing Codebase with Numba
 
Cooking a rabbit pie
Cooking a rabbit pieCooking a rabbit pie
Cooking a rabbit pie
 
OpenMP
OpenMPOpenMP
OpenMP
 
Real time system_performance_mon
Real time system_performance_monReal time system_performance_mon
Real time system_performance_mon
 
Want to write a book in Jupyter - here's how
Want to write a book in Jupyter - here's howWant to write a book in Jupyter - here's how
Want to write a book in Jupyter - here's how
 
Python for ML.pptx
Python for ML.pptxPython for ML.pptx
Python for ML.pptx
 
PyData Boston 2013
PyData Boston 2013PyData Boston 2013
PyData Boston 2013
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"
 
Building SciPy kernels with Pythran
Building SciPy kernels with PythranBuilding SciPy kernels with Pythran
Building SciPy kernels with Pythran
 
Numba lightning
Numba lightningNumba lightning
Numba lightning
 
An Introduction to PyPy
An Introduction to PyPyAn Introduction to PyPy
An Introduction to PyPy
 
Preparing Codes for Intel Knights Landing (KNL)
Preparing Codes for Intel Knights Landing (KNL)Preparing Codes for Intel Knights Landing (KNL)
Preparing Codes for Intel Knights Landing (KNL)
 

Kürzlich hochgeladen

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 

Kürzlich hochgeladen (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 

Numba Overview

  • 1. Numba:
 A JIT Compiler for Scientific Python 1 Stan Seibert Continuum Analytics January 22, 2015
  • 2. Why Python? • For many programs, the most important resource is developer time. • The best code is: • Easy to read • Easy to understand • Easy to modify • But sometimes execution speed does matter.
 Then what do you do? 2
  • 3. Achieving Performance in Python When you need speed in Python the most important things you can do are: 1. Use profiling to understand where your program spends time.
 (Most of your code is irrelevant. Only worry about the parts that matter.) 2. Leverage NumPy and SciPy when working with numerical code. 3. Take a look at Numba… 3
  • 4. How can Numba help? • Numba is an open source Just-In-Time compiler for Python functions. • From the types of the function arguments, Numba can often generate a specialized, fast, machine code implementation at runtime. • Designed to work best with numerical code and NumPy arrays. • Uses the LLVM library as the compiler backend. 4
  • 5. Numba Features • Numba supports: • Windows (XP and later), OS X (10.7 and later), and Linux • 32 and 64-bit x86 CPUs and NVIDIA GPUs • Python 2 and 3 • NumPy versions 1.6 through 1.9 • It does not require a C/C++ compiler on the user’s system. • Requires less than 70 MB to install. • Does not replace the standard Python interpreter
 (all of your existing Python libraries are still available) 5
  • 6. Creating a Ufunc • Numba is the best way to make new ufuncs for working with NumPy arrays 6
  • 7. Compiling a Function • Sometimes you can’t create a simple or efficient array expression or ufunc. Use Numba to work with array elements directly. • Example: Suppose you have a boolean grid and you want to find the maximum number neighbors a cell has in the grid: 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 3 2 1 2 2 1 1 2 1 2 2 2 2 2 1 1 1 1 1 1 1 1
  • 9. Compiling a Function • Very hard to express this calculation purely as array operations (and even if you do, it is likely unreadable to non-NumPy experts). • Numba let’s you write out the loops, but avoid the penalty for having to loop over individual elements in the Python interpreter: 169x faster! 9
  • 10. Different Modes of Compilation • Numba automatically selects between two different levels of optimization when compiling a function: • “object mode”: supports nearly all of Python, but generally cannot speed up code by a large factor
 (exception: see next slide) • “nopython mode”: supports a subset of Python, but runs at C/C++/FORTRAN speeds 10
  • 11. Loop-Lifting • In object mode, Numba will attempt to extract loops and compile them in nopython mode. • Works great for functions that are bookended by uncompilable code, but have a compilable core loop. • All happens automatically. 11
  • 13. Nopython Mode Features • Standard control and looping structures: if, else, while, for, range • NumPy arrays, int, float, complex, booleans, and tuples • Almost all arithmetic, logical, and bitwise operators as well as functions from the math and numpy modules • Nearly all NumPy dtypes: int, float, complex, datetime64, timedelta64 • Array element access (read and write) • Array reduction functions: sum, prod, max, min, etc • Calling other nopython mode compiled functions • Calling ctypes or cffi-wrapped external functions 13
  • 14. Compiling for the GPU GPU functions are called differently, but it is still Python! MacBook Pro w/ GTX 650M GPU
  • 15. Advanced Use Cases • Compile new functions based on user input. • Great for inserting a user-provided math expression into a larger algorithm, while still achieving C speeds. • Optimization (least squares, etc) libraries that can recompile themselves to inline a specific objective function right into the algorithm • Multithreaded calculation without having to worry about the global interpreter lock (GIL). 15
  • 16. NumbaPro • NumbaPro adds higher level features on top of Numba: • Create ufuncs that run multithreaded on the CPU or on the GPU • GPU linear algebra • GPU FFTs 16
  • 17. Conclusion • Numba is a JIT compiler than understands Python! • Achieve the same speeds as compiled languages for numerical and array-processing code. • Can be used to create advanced workflows where user input drives compilation at runtime. • Open source, available at: http://numba.pydata.org/ • Or: conda  install  numba 17