ImportError: No module named _driver

Hi all,
I just installed pycuda and tried to run a pycuda example. Its first line ‘import pycuda.driver as cuda’ gives an error. I have searched before posting this and found a thread here
This was solution given: "It turns out, if you try to import any of the pycuda files while you are in the directory that you extracted the pycuda tar.gz file (for me it was ~/Desktop/pycuda-0.94.2) then they will fail with the above error. All you have to do to fix this is be in another directory. Hopefully this saves someone some time. "

like he said i got error when i was in pycuda-2011.2.2:
user@ubuntu:~/pycuda-2011.2.2$ python
Python 2.7.3 (default, Apr 20 2012, 22:39:59)
[GCC 4.6.3] on linux2

import pycuda.driver as cuda
Traceback (most recent call last):
File “”, line 1, in
File “pycuda/driver.py”, line 2, in
from pycuda._driver import *
ImportError: No module named _driver

But i got error here too:
user@ubuntu:~$ python

import pycuda.driver as cuda
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python2.7/dist-packages/pycuda-2011.2.2-py2.7-linux-x86_64.egg/pycuda/driver.py”, line 2, in
from pycuda._driver import *
ImportError: libcurand.so.4: wrong ELF class: ELFCLASS32

I am not sure what he meant by different directory. Any suggestion/thoughts ?

Problem is clear, Python is x86_64 while libcurand is a 32bit binary, so it cannot be dyn loaded…

Either pycuda was configured with the wrong cuda lib path (should be /usr/local/lib64) or you have a bad LD_LIBRARY_PATH

Thanks for response.

I have added this in ~/.bashrc-> export LD_LIBRARY_PATH=/usr/local/cuda/lib.

Looks like i picked wrong info. from somewhere.

I changed it to /usr/local/cuda/lib64. Now “import pycuda.driver as cuda” works.

Thank You.

1question :

I just read in nvidia forum, someone said that, “LD_LIBRARY_PATH or /etc/ld.so.conf should contain both the cuda/lib and cuda/lib64 directories”.

while other said that, “Apparantly its in the release notes setLD_LIBRARY_PATH to /usr/local/cuda/lib64 not /usr/local/cuda/lib.If you are on a 64 bit platform”.

Is first person right ? I don’t have any errors now.

edit: I found something else too. After making it lib64, if i run python from “user@ubuntu:~/pycuda-2011.2.2$” it gives same error which i mentioned in first post. But from “user@ubuntu:~$” no error, like solution mentioned in first post.

Hi everybody,

I have checked the cuda, pycuda.whl and python versions carefully, and set the path in the environment variables. But I still got the similar error when loading the “import pycuda.autoinit”.

May I kindly have some advice? Many thanks.
Best Regards,

make sure the python you are using is a 64-bit python

For me it worked to move up one directory-- instead of running pycuda in the top level of GitHub - inducer/pycuda: CUDA integration for Python, plus shiny features, just move one directory higher.