Discussion:
Windows <--> Linux interchangeable code?
(too old to reply)
Benedikt Kopp
2017-06-19 16:16:30 UTC
Permalink
Dear all,
I'm having a few problems with pycuda in combination with Ubuntu 16.04 and
cuda 8.0.

I've tried to make a minimal working error-example that I run on both
Windows and Linux:

*import numpy as np*
*import pycuda.autoinit*
*import pycuda.driver as cuda*
*from pycuda.compiler import SourceModule*


*def main():*

* test_array = np.arange(0,20,1).astype(np.float32)*

* mod = SourceModule("""*
* __global__ void addtwo(float *input){*
* int n = threadIdx.x;*
* input[n] = input[n]+2;*
* }*
* """)*

* addtwo = mod.get_function('addtwo')*

* addtwo(cuda.InOut(test_array),grid=(1,1),block=(np.int32(20),1,1))*


*if __name__ == '__main__':* *main()*

*which on linux gives me the following error*


*ArgumentError Traceback (most recent call
last)*
*<ipython-input-2-58ca95c5b364> in <module>()*
*----> 1 main()*

*<ipython-input-1-812e11d7dfa9> in main()*
* 17 *
* 18 addtwo = mod.get_function('addtwo')*
*---> 19
addtwo(cuda.InOut(test_array),grid=(1,1),block=(np.int32(20),1,1))*

*/usr/lib/python2.7/dist-packages/pycuda/driver.pyc in function_call(func,
*args, **kwargs)*
* 380 raise ValueError("must specify block size")*
* 381 *
*--> 382 func._set_block_shape(*block)*
* 383 handlers, arg_buf = _build_arg_buf(args)*
* 384 *

*ArgumentError: Python argument types in*
* Function._set_block_shape(Function, numpy.int32, int, int)*
*did not match C++ signature:*
* _set_block_shape(pycuda::function {lvalue}, int, int, int)*



whereas, when I run it on Windows, it runs just fine.
Also, for both systems, when I change the block size to block=(20,1,1), it
runs completely fine.

My question now is:
Is this a bug?
Are there more differences between Windows and Linux that I have to look
out for?
Is it even possible to write pycuda code that is interchangeable between
windows and linux?

I've been working on this error for more than a week now and I would very
much appreciate your help!
Best regards,
Ben

PS: I've tried to look up the archive for this mailing list, but I can't
reach http://news.gmane.org/gmane.comp.python.cuda
Andreas Kloeckner
2017-06-21 12:07:29 UTC
Permalink
Benedikt,
Post by Benedikt Kopp
I'm having a few problems with pycuda in combination with Ubuntu 16.04 and
cuda 8.0.
I've tried to make a minimal working error-example that I run on both
You may notice that you're passing a numpy.int32 for the block
shape. It's quite possible that that's permissible in Linux and not
permissible in Windows, based on the versions of Boost Python and Numpy
that are being used. Not passing a numpy integer (just a plain Python
int) should work.

Regarding the list, there's still a (non-searchable, unfortunately)
archive of the list here:

https://lists.tiker.net/listinfo/pycuda

Andreas
Eric Larson
2017-06-21 13:11:45 UTC
Permalink
Post by Andreas Kloeckner
Regarding the list, there's still a (non-searchable, unfortunately)
https://lists.tiker.net/listinfo/pycuda
FYI if you want to search, you can Google e.g.:

site:https://lists.tiker.net/pipermail/pycuda kernel

And it will search the list for "kernel".

Eric

Loading...