例外:版本不匹配:这是'cffi'软件包1.13.1版本, - python

我尝试使用CUDA运行代码,但出现此错误,系统似乎有问题

完整代码:我得到了CUDACast #10a - Your First CUDA Python Program和no module named numbapro

import numpy as np
from timeit import default_timer as timer
from numba import vectorize

@vectorize(["float32(float32, float32)"], target='cuda')


def VectorAdd(a, b):
        return a + b

def main():
    N = 32000000

    A = np.ones(N, dtype=np.float32)
    B = np.ones(N, dtype=np.float32)
    C = np.zeros(N, dtype=np.float32)

    start = timer()
    C = VectorAdd(A, B)
    vectoradd_timer = timer() - start

    print("C[:5] = " + str(C[:5]))
    print("C[-5:] = " + str(C[-5:]))

    print("VectorAdd took %f seconds" % vectoradd_timer)

if __name__ == '__main__':
    main()

输出:

例外:版本不匹配:这是'cffi'软件包版本
1.13.1,位于“ /usr/local/lib/python2.7/dist-packages/cffi/api.pyc”中。当我们导入
最顶层的“ _cffi_backend”扩展模块,我们获得的版本为1.5.2,
位于
'/usr/lib/python2.7/dist-packages/_cffi_backend.x86_64-linux-gnu.so'。
这两个版本应该相等;检查您的安装。

也许是这个原因:

$which pip
/usr/bin/pip

python大神给出的解决方案

您必须尝试分别删除所有cffi软件包和已安装的版本1.5.2

sudo pip install cffi==1.5.2

或者,您可以通过更新旧版本来确保版本一致。

sudo apt-get install python-cffi

希望对您有帮助

Python:同时在for循环中添加到列表列表 - python

我想用for循环外的0索引值创建一个新列表,然后使用for循环添加到相同的列表。我的玩具示例是:import random data = ['t1', 't2', 't3'] masterlist = [['col1', 'animal1', 'an…

用大写字母拆分字符串,但忽略AAA Python Regex - python

我的正则表达式:vendor = "MyNameIsJoe. I'mWorkerInAAAinc." ven = re.split(r'(?<=[a-z])[A-Z]|[A-Z](?=[a-z])', vendor) 以大写字母分割字符串,例如:'我的名字是乔。 I'mWorkerInAAAinc”变成…

在Python中迭代OrderedDict - python

我有以下OrderedDict:OrderedDict([('r', 1), ('s', 1), ('a', 1), ('n', 1), ('y', 1)]) 实际上,这表示单词中字母的出现频率。第一步-我将使用最后两个元素来创建一个这样的联合元组; pair…

如果__name__ =='__main__',则为Python的Powershell等效项: - python

我真的很喜欢python的功能,例如:if __name__ == '__main__': #setup testing code here #or setup a call a function with parameters and human format the output #etc... 很好,因为我可以将Python脚本文件…

Matplotlib表行标签字体的颜色和大小 - python

给出下表:import matplotlib.pyplot as plt table=plt.table(cellText=[' ', ' ', ' ', ' ', ' '], # rows of data values rowLabels=['1&…