2

I am trying to install pycuda to do some image processing in python. I followed the following link to install it :

https://www.ibm.com/developerworks/community/blogs/jfp/entry/Installing_PyCUDA_On_Anaconda_For_Windows?lang=en

I feel I have installed everything right but when I run the sample code using pycharm:

import pycuda.autoinit
import pycuda.driver as drv
import numpy

from pycuda.compiler import SourceModule
mod = SourceModule("""
__global__ void multiply_them(float *dest, float *a, float *b)
{
  const int i = threadIdx.x;
  dest[i] = a[i] * b[i];
}
""")

multiply_them = mod.get_function("multiply_them")

a = numpy.random.randn(400).astype(numpy.float32)
b = numpy.random.randn(400).astype(numpy.float32)

dest = numpy.zeros_like(a)
multiply_them(
        drv.Out(dest), drv.In(a), drv.In(b),
        block=(400,1,1), grid=(1,1))

print (dest-a*b)

I get the error :

ModuleNotFoundError: No module named 'pycuda.autoinit'; 'pycuda' is not a package

When I run in the CMD, I get

File "C:\Users\Nitharshini\Miniconda3\lib\site-packages\pycuda\au‌​toinit.py", line 2, in <module> 
    import pycuda.driver as cuda 
File "C:\Users\Nitharshini\Miniconda3\lib\site-packages\pycuda\dr‌​iver.py", line 5, in <module> 
    from pycuda._driver import * 
# noqa ImportError: DLL load failed: The specified module could not be found.

Any idea why this is happening?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
nithu
  • 29
  • 3
  • `from pycuda import autoinit`? Please show `pip freeze` and `python --version` to show what's installed and the version you're running – OneCricketeer Aug 28 '17 at 19:43
  • tried that but the i get the following error: ImportError: cannot import name 'autoint' – nithu Aug 28 '17 at 19:45
  • I am running python version 3.6 – nithu Aug 28 '17 at 19:46
  • On my computer, I use either `pip3 install` or `python3 -m pip install`. – OneCricketeer Aug 28 '17 at 19:47
  • I am using a windows 10 laptop. I know that pycuda is already installed cause when I do pip install, it says requirements are already satisfied – nithu Aug 28 '17 at 19:49
  • Then you've not setup PyCharm to use that same python installation – OneCricketeer Aug 28 '17 at 20:09
  • my pycharm intepreter is anaconda using which I had installed pycuda. Is there some other setup that I need to do in pycharm? – nithu Aug 28 '17 at 20:15
  • So, are you using pure Python 3.6 from http://python.org or Anaconda? – OneCricketeer Aug 28 '17 at 20:17
  • i am using anaconda with pycharm as my ide – nithu Aug 28 '17 at 20:20
  • Open the Anaconda REPL, and import your library. If it works, then your problem is PyCharm's interpreter setting – OneCricketeer Aug 28 '17 at 21:02
  • I am sorry but I don't truly understand how to do that. What exactly is a REPL and how do I import the library? – nithu Aug 28 '17 at 21:07
  • Open a Command prompt. Run `python` Run `import pycuda.autoinit` – OneCricketeer Aug 28 '17 at 21:37
  • File "C:\Users\Nitharshini\Miniconda3\lib\site-packages\pycuda\autoinit.py", line 2, in import pycuda.driver as cuda File "C:\Users\Nitharshini\Miniconda3\lib\site-packages\pycuda\driver.py", line 5, in from pycuda._driver import * # noqa ImportError: DLL load failed: The specified module could not be found. – nithu Aug 28 '17 at 22:55
  • This is the error I get when I do that – nithu Aug 28 '17 at 22:55
  • Looks like you are using miniconda, not anaconda. Also `DLL load failed` likely means you've not installed the prerequisites like the CUDA libraries or Microsoft C++ linker libraries – OneCricketeer Aug 28 '17 at 23:05
  • Can you give me some links to install the CUDA libraries. I have installed CUDA toolkit. Anything else I might need to install? – nithu Aug 28 '17 at 23:49

0 Answers0