1
votes

I'm trying to learn how to use pyculib and got AttributeError: module 'numba.findlib' has no attribute 'get_lib_dir'

4 core CPU (intel) + GeForce GTX 745

File "", line 1, in runfile('C:/Python/Scripts/LearnCUDA/curand.py', wdir='C:/Python/Scripts/LearnCUDA')

File "C:\Users\Administrator\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 786, in runfile execfile(filename, namespace)

File "C:\Users\Administrator\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Python/Scripts/LearnCUDA/curand.py", line 11, in from pyculib import rand as curand

File "C:\Users\Administrator\Anaconda3\lib\site-packages\pyculib__init__.py", line 49, in from . import blas, sparse, fft, rand, sorting

File "C:\Users\Administrator\Anaconda3\lib\site-packages\pyculib\sorting__init__.py", line 1, in from .radixsort import RadixSort

File "C:\Users\Administrator\Anaconda3\lib\site-packages\pyculib\sorting\radixsort.py", line 38, in lib = load_lib('radixsort')

File "C:\Users\Administrator\Anaconda3\lib\site-packages\pyculib\sorting\common.py", line 24, in load_lib libpath = os.path.join(findlib.get_lib_dir(), fullname)

AttributeError: module 'numba.findlib' has no attribute 'get_lib_dir'

import numpy as np
from pyculib import rand as curand

prng = curand.PRNG(rndtype=curand.PRNG.XORWOW)
rand = np.empty(100000)
prng.uniform(rand)
print(rand[:10])
2
What is your version of cudatoolkit and cudaDuck_dragon
Now I tried to reinstall them and got the following:user3553069
for cuda: PackagesNotFoundError: The following packages are not available from current channels: cudauser3553069
And for cudatoolkit: # All requested packages already installed.user3553069
after running numba -s I've got:: cudatoolkit 9.0 1 and cudnn 7.3.1 cuda9.0_0user3553069

2 Answers

1
votes

Navigate to C:\Users\Administrator\Anaconda3\lib\site-packages\pyculib\sorting\ and make a back up of common.py. Replace the code in common.py with

from numba import findlib
import ctypes
import os
import platform
import warnings

def library_extension():
    p = platform.system()
    if p == 'Linux':
        return 'so'
    if p == 'Windows':
        return 'dll'
    if p == 'Darwin':
        return 'dylib'

def load_lib(libname):
    fullname = 'pyculib_%s.%s' % (libname, library_extension())
    devlib = os.path.join(os.path.abspath(os.path.dirname(__file__)), fullname)
    if os.path.exists(devlib):
        libpath = devlib
        warnings.warn('Using in-tree library %s' % libpath)
    else:
        libpath = os.path.join(findlib.get_lib_dirs()[0], fullname)

    return ctypes.CDLL(libpath)

If this dosent fix the problem revert to your backup

0
votes

The following steps solved the problem for me:

  1. Download anaconda 3-5.1.0
  2. Install numpy using conda install numpy=1.13.0
  3. Install cudatoolkit 7.5 using conda install cudatoolkit=7.5
  4. Install pyculib.
    If it works then every thing is ok, if you have an error like CURAND_STATUS_LAUNCH_FAILURE when using Anaconda Accelerate on GTX 1060 you can then:
  5. Install cudatoolkit=8.0 using conda install -c numba cudatoolkit=8.0