1

My setup: Windows 10 64 bit (including all patches) QGIS 3.0.0-Girona

My issue: Installing numba not working

why: I want to use GPU to process my python scripts

Details: I followed the following:

  1. OSGeo4W: typed "curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py"
  2. OSGeo4w: typed "python get-pip.py"
  3. OSGeo4w: typed "python -m pip install numba"
  4. OSGeo4W: typed again "python -m pip install numba" and get...

Requirement already satisfied: numba in c:\progra~1\qgis3~1.0\apps\python27\lib\site-packages

Requirement already satisfied: funcsigs in c:\progra~1\qgis3~1.0\apps\python27\lib\site-packages (from numba)

Requirement already satisfied: singledispatch in c:\progra~1\qgis3~1.0\apps\python27\lib\site-packages (from numba)

Requirement already satisfied: numpy in c:\progra~1\qgis3~1.0\apps\python27\lib\site-packages (from numba)

Requirement already satisfied: llvmlite>=0.22.0.dev0 in c:\progra~1\qgis3~1.0\apps\python27\lib\site-packages (from numba)

Requirement already satisfied: enum34 in c:\progra~1\qgis3~1.0\apps\python27\lib\site-packages (from numba)

Requirement already satisfied: six in c:\progra~1\qgis3~1.0\apps\python27\lib\site-packages (from singledispatch->numba)

  1. OSGeo4w: typed "python" and from prompt typed "import numba" *no issues
  2. QGIS python plugin: typed "import numba" and get...

    import numba
    Traceback (most recent call last): File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\code.py", line 91, in runcode exec(code, self.locals) File "", line 1, in File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python\qgis\utils.py", line 664, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ModuleNotFoundError: No module named 'numba'

I'm I doing something wrong here? If I install numba in OSGeo4W, is that supposed to be represented in QGIS?

From OSGeo4W, from...

import numba
print(numba.__version__)

I get 0.37.0

3
  • Do you have both Python2.7 and 3.6 installed? Seems to produce conflicts. With Python3 pip should be already installed. Try to use only python3 since this is the Standard for QGis3 Mar 16, 2018 at 23:13
  • 1
    You're installing the python 2.7 version - Requirement already satisfied: numba in c:\progra~1\qgis3~1.0\apps\**python27**\lib\site-packages. Use pip3 install numba instead
    – user2856
    Mar 17, 2018 at 0:12
  • Andreas and Luke, you are both correct. With your help I was able to resolve the issue. Many thanks!
    – abc def
    Mar 17, 2018 at 15:47

1 Answer 1

2

I managed to get numba installed by following these steps

  1. Removed default QGIS installation
  2. Downloaded OSGeo4W setup, ran it and only installed QGIS GUI and python 3 (latest) by doing an Advanced installation enter image description here enter image description here enter image description here
    1. OSGeo4W installed all the required dependencies

When OSGeo4W completed installations...

  1. OSGeo4W: typed "curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py"
  2. OSGeo4w: typed "python get-pip.py"
  3. OSGeo4w: typed "python -m pip install numba"
  4. OSGeo4W: typed again "python -m pip install numba"

I have numba installed and running in both OSGeo4w (command prompt) and from python plugin within the GUI.

I can now get a handle to numba and can run the following code from the OSGeo4W prompt using "Python3 Cuda_yes.py"

import numpy as np
import os
os.environ['NUMBAPRO_NVVM']=r'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\nvvm\bin\nvvm64_32_0.dll'
os.environ['NUMBAPRO_LIBDEVICE']=r'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\nvvm\libdevice'

from timeit import default_timer as timer
from numba import vectorize

@vectorize(['float32(float32, float32)'], target='cuda')
def pow(a, b):
    return a ** b

vec_size = 100000000

a = b = np.array(np.random.sample(vec_size), dtype=np.float32)
c = np.zeros(vec_size, dtype=np.float32)

start = timer()
c = pow(a, b)
duration = timer() - start

print(duration)

I'm going to close this thread because install numba is resolved and I can run code in OSGeo4W.
Will open a new thread/question to resolve inability to run the above in QGIS GUI.

1
  • Python 3 includes pip. No need to reinstall it.
    – user2856
    Mar 18, 2018 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.