Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception: Version mismatch: this is the 'cffi' package version 1.13.1,

Tags:

python

pip

numba

I tried to run the code using CUDA, I got this error, it seems something wrong in the system

the full code: I got it CUDACast #10a - Your First CUDA Python Program and 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()

the output:

Exception: Version mismatch: this is the 'cffi' package version 1.13.1, located in '/usr/local/lib/python2.7/dist-packages/cffi/api.pyc'. When we import the top-level '_cffi_backend' extension module, we get version 1.5.2, located in '/usr/lib/python2.7/dist-packages/_cffi_backend.x86_64-linux-gnu.so'. The two versions should be equal; check your installation.

maybe this reason:

$which pip
/usr/bin/pip
like image 493
Redhwan Avatar asked Mar 04 '23 06:03

Redhwan


2 Answers

You have to try by removing all the cffi packages separately and installed version 1.5.2.

sudo pip install cffi==1.5.2

Or you can make sure the version is consistent by updating the old version.

sudo apt-get install python-cffi

Hope it helps you

like image 196
Saleem Ali Avatar answered Apr 07 '23 17:04

Saleem Ali


updating pip to the latest version solved my problem.

pip3 install --upgrade pip
like image 20
Felipe Ferreira Avatar answered Apr 07 '23 18:04

Felipe Ferreira