Installing Pycuda and using Pycharm

2k Views Asked by At

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?

0

There are 0 best solutions below