I've also had similar problems interoperating between the GPUArray class in PyCUDA and external libraries, although I never spent the time to figure out exactly what was going on. It might be interesting to try using your find_positive function with pointers that you allocated and moved to the GPU manually (using pycuda.driver.mem_alloc() and pycuda.driver.memcpy_htod, etc.), rather than using to_gpu() to create a GPUArray.
- bryan
On Feb 5, 2010, at 9:01 AM, Dan Goodman wrote:
> Hi all,
>
> I've just installed the CUDA 3.0b and PyCUDA 0.94beta and I still get the
> same problem. Any other ideas?
>
> Dan
>
> On 03/02/2010 23:06, Dan Goodman wrote:
>> Thanks for the quick reply Bryan. Indeed, I'm not using CUDA 3.0b - in
>> fact the fact that it had come out totally passed me by! Does this mean
>> that for the next release of PyCUDA we will be able to have BLAS access
>> working with PyCUDA? I seem to remember this driver/runtime API was the
>> issue there. And I think you must be right that it's the problem here
>> too. Thanks!
>>
>> Dan
>>
>> On 03/02/2010 19:13, Bryan Catanzaro wrote:
>> > Are you using CUDA 3.0b? PyCUDA uses the driver API, while chag:pp
>> probably uses the runtime API. Before CUDA 3.0b, trying to interoperate
>> between the two causes segmentation faults like what you seem to be seeing.
>> >
>> > - bryan
>> >
>> > On Feb 3, 2010, at 9:18 AM, Dan Goodman wrote:
>> >
>> >> Hi all,
>> >>
>> >> I have a problem and almost a solution, but my program crashes after
>> running and giving the right output. The problem is to use an external
>> library, in this case chag:pp [1] which is a header file only library,
>> along with PyCUDA. What I'm trying to do is to use their compaction
>> algorithm on a pycuda array. I've successfully built a DLL from a C++
>> file which basically does this:
>> >>
>> >> struct Predicate
>> >> {
>> >> __device__ bool operator() (double value) const
>> >> {
>> >> return value>0.0;
>> >> }
>> >> };
>> >> void find_positive(
>> >> int x_gpu_start,
>> >> int x_gpu_end,
>> >> int y_gpu_start,
>> >> int count_start
>> >> )
>> >> {
>> >> pp::compact(
>> >> (double *)x_gpu_start, /* Input start pointer */
>> >> (double *)x_gpu_end, /* Input end pointer */
>> >> (double *)y_gpu_start, /* Output start pointer */
>> >> (size_t *)count_start, /* Storage for valid element count */
>> >> Predicate() /* Predicate */
>> >> );
>> >> }
>> >>
>> >> I'm then using ctypes to load this library and call that function,
>> like this:
>> >>
>> >> lib = cdll.LoadLibrary('testchagpp')
>> >> find_positive = lib.find_positive
>> >> x = randn(100)
>> >> y = to_gpu(x)
>> >> out = to_gpu(zeros(len(x)))
>> >> count = to_gpu(array([0], dtype=int))
>> >> find_positive(int(y.gpudata), int(y.gpudata)+len(x)*8,
>> >> int(out.gpudata), int(count.gpudata))
>> >>
>> >>
>> >> The program works, in that it correctly compacts the array x into
>> the array y, but afterwards I get the error:
>> >>
>> >> This application has requested the Runtime to terminate it in an
>> unusual way.
>> >> Please contact the application's support team for more information.
>> >>
>> >> I'm on 64 bit Windows 7, but using a 32 bit build of Python, PyCuda,
>> etc.
>> >>
>> >> I see two possibilities. Possibility 1: I've just made a mistake
>> somewhere about something obvious, and this approach should work.
>> Possibility 2: I can't pass pycuda data to the DLL file and this causes
>> something to break somewhere.
>> >>
>> >> Any ideas?
>> >>
>> >> Many thanks,
>> >> Dan Goodman
>> >>
>> >> [1] http://www.cse.chalmers.se/~billeter/pub/pp/
>> >>
>> >> _______________________________________________
>> >> PyCUDA mailing list
>> >> [email protected]
>> >> http://host304.hostmonster.com/mailman/listinfo/pycuda_tiker.net
>> >
>>
>>
>> _______________________________________________
>> PyCUDA mailing list
>> [email protected]
>> http://host304.hostmonster.com/mailman/listinfo/pycuda_tiker.net
>>
>
>
> _______________________________________________
> PyCUDA mailing list
> [email protected]
> http://host304.hostmonster.com/mailman/listinfo/pycuda_tiker.net
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ PyCUDA mailing list [email protected] http://host304.hostmonster.com/mailman/listinfo/pycuda_tiker.net
