I installed and used Numba with Python3.5

environment

Ubuntu 16.04

Installation method

This Installed

#install llvm(If you put it in, the version is 3.Was 8)
$ sudo apt-get install llvm #Other packages were originally included
$ sudo pip3 install enum34 funcsigs
$ sudo LLVM_CONFIG=/usr/bin/llvm-config-3.8 pip3 install llvmlite
$ sudo LLVM_CONFIG=/usr/bin/llvm-config-3.8 pip3 install numba

Run

I'm not sure if time is good for measuring time, but I just want to get a rough idea, so I don't really care.

import time
import numpy as np
import numba

@numba.jit
def rando(a):
    for i in range(N):
        for j in range(N):
            a[i][j] = np.random.rand()
    return a

start = time.time()
N = 100
a = np.zeros((N, N))
for i in range(1000):
    a = rando(a)

end = time.time()

print(end - start)

You can compare the times by commenting out the @ numba.jit part. It was 1.46s when not commented out and 26.68s when commented out **, which was more than 20 times faster **. On the other hand, when the number of loops was changed from 1000 to 1, it was 0.025s when not commented out and 0.541s when commented out, which was faster without using numba. It still takes a long time to compile at the very beginning.

The first image is the image when the number of loops is around 0, and the second image is the image of the overall elapsed time. The vertical axis is time (seconds), the horizontal axis is the number of loops, green is without numba, and blue is with numba. around1.png global.png

Recommended Posts

I installed and used Numba with Python3.5
I played with PyQt5 and Python3
[Python] I introduced Word2Vec and played with it.
I tried Jacobian and partial differential with python
I tried function synthesis and curry with python
I tried fp-growth with python
Programming with Python and Tkinter
I tried scraping with Python
Encryption and decryption with Python
Python and hardware-Using RS232C with Python-
I installed and used the Deep Learning library Chainer
I want to handle optimization with python and cplex
I made blackjack with python!
Findings when accelerating numerical calculations with Python and Numba
I compared Java and Python!
I tried speeding up Python code including if statements with Numba and Cython
I made a LINE BOT with Python and Heroku
python with pyenv and venv
I tried gRPC with Python
I tried scraping with python
I implemented collaborative filtering (recommendation) with redis and python
I made blackjack with Python.
I made wordcloud with Python.
Works with Python and R
I tried follow management with Twitter API and Python (easy)
[Python] I installed the game from pip and played it
I tried to make GUI tic-tac-toe with Python and Tkinter
This time I learned python III and IV with Prorate
Communicate with FX-5204PS with Python and PyUSB
TensorFlow 2.2 can't be installed with Python 3.8!
Shining life with Python and OpenCV
Install Python 2.7.9 and Python 3.4.x with pip.
Neural network with OpenCV 3 and Python 3
AM modulation and demodulation with python
[Python] font family and font with matplotlib
Scraping with Node, Ruby and Python
I can't install python3 with pyenv-vertualenv
I tried web scraping with python.
Scraping with Python and Beautiful Soup
I sent an SMS with Python
JSON encoding and decoding with python
Hadoop introduction and MapReduce with Python
[GUI with Python] PyQt5-Drag and drop-
Reading and writing NetCDF with Python
I liked the tweet with python. ..
Roughly speed up Python with numba
Reading and writing CSV with Python
Multiple integrals with Python and Sympy
I want to debug with Python
I tried running prolog with python 3.8.2.
Coexistence of Python2 and 3 with CircleCI (1.0)
Easy modeling with Blender and Python
I made a daemon with Python
I tried SMTP communication with Python
Sugoroku game and addition game with python
FM modulation and demodulation with Python
When I installed python on macOS and used it, I got an error when I put an https connection
I made a simple circuit with Python (AND, OR, NOR, etc.)
I couldn't use tkinter with python installed by pyenv of anyenv
[Python] Until CuPy is installed on Windows 10 and CUDA core is used
I want to solve APG4b with Python (only 4.01 and 4.04 in Chapter 4)