我正在尝试学习如何使用pyculib并得到AttributeError:模块'numba.findlib'没有属性'get_lib_dir'
4核CPU(英特尔)+ GeForce GTX 745
文件“”,第1行,在 runfile('C:/Python/Scripts/LearnCUDA/curand.py',wdir ='C:/ Python / Scripts / LearnCUDA')
runfile中的文件“ C:\ Users \ Administrator \ Anaconda3 \ lib \ site-packages \ spyder_kernels \ customize \ spydercustomize.py”,行786 execfile(文件名,命名空间)
exec文件中的第110行,文件“ C:\ Users \ Administrator \ Anaconda3 \ lib \ site-packages \ spyder_kernels \ customize \ spydercustomize.py” exec(compile(f.read(),文件名,'exec'),命名空间)
文件“ C:/Python/Scripts/LearnCUDA/curand.py”,第11行,在 从pyculib import rand作为curand
文件“ C:\ Users \ Administrator \ Anaconda3 \ lib \ site-packages \ pyculib__init __。py”,第49行,在 来自。导入blas,sparse,fft,rand,sort
文件“ C:\ Users \ Administrator \ Anaconda3 \ lib \ site-packages \ pyculib \ sorting__init __。py”,第1行,在 从.radixsort导入RadixSort
文件“ C:\ Users \ Administrator \ Anaconda3 \ lib \ site-packages \ pyculib \ sorting \ radixsort.py”,第38行,在 lib = load_lib('radixsort')
load_lib中的第24行,文件“ C:\ Users \ Administrator \ Anaconda3 \ lib \ site-packages \ pyculib \ sorting \ common.py” libpath = os.path.join(findlib.get_lib_dir(),全名)
AttributeError:模块'numba.findlib'没有属性'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])
答案 0 :(得分:0)
导航到C:\Users\Administrator\Anaconda3\lib\site-packages\pyculib\sorting\
并备份common.py。用
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)
如果此修复方法可以解决问题,请还原为您的备份
答案 1 :(得分:0)
以下步骤为我解决了这个问题:
conda install numpy=1.13.0
conda install cudatoolkit=7.5
CURAND_STATUS_LAUNCH_FAILURE
的错误
然后,您可以:conda install -c numba cudatoolkit=8.0
安装cudatoolkit = 8.0