elodw <a...@pdauf.de> writes:
> with
>
> import pycuda.gpuarray as gpuarray
> import pycuda.driver as drv
> import pycuda.autoinit
> import numpy
> import sys
>
> from pycuda.tools import mark_cuda_test
> from pycuda.characterize import has_double_support
>
> from pycuda.compiler import SourceModule
> .....
> ....
> zzz=gpuarray.sum(pow(yyy-xxx,2))           -------Error statement
> ....
> ....
>
> i get the following error message:
>
> Traceback (most recent call last):
>    File "/home/brust/PyCUDA/matmul17.py", line 36, in <module>
>      zzz=gpuarray.sum(pow(yyy-xxx,2))
>    File "/usr/lib/python2.7/dist-packages/pycuda/gpuarray.py", line 623, 
> in __pow__
>      func = elementwise.get_pow_kernel(self.dtype)
>    File "<string>", line 2, in get_pow_kernel
>    File "/usr/lib/python2.7/dist-packages/pycuda/tools.py", line 404, in 
> context_dependent_memoize
>      result = func(*args)
>    File "/usr/lib/python2.7/dist-packages/pycuda/elementwise.py", line 
> 549, in get_pow_kernel
>      "pow_method")
>    File "/usr/lib/python2.7/dist-packages/pycuda/elementwise.py", line 
> 165, in get_elwise_kernel
>      arguments, operation, name, keep, options, **kwargs)
>    File "/usr/lib/python2.7/dist-packages/pycuda/elementwise.py", line 
> 151, in get_elwise_kernel_and_types
>      keep, options, **kwargs)
>    File "/usr/lib/python2.7/dist-packages/pycuda/elementwise.py", line 
> 75, in get_elwise_module
>      options=options, keep=keep)
>    File "/usr/lib/python2.7/dist-packages/pycuda/compiler.py", line 262, 
> in __init__
>      arch, code, cache_dir, include_dirs)
>    File "/usr/lib/python2.7/dist-packages/pycuda/compiler.py", line 252, 
> in compile
>      return compile_plain(source, options, keep, nvcc, cache_dir)
>    File "/usr/lib/python2.7/dist-packages/pycuda/compiler.py", line 134, 
> in compile_plain
>      cmdline, stdout=stdout.decode("utf-8"), stderr=stderr.decode("utf-8"))
> pycuda.driver.CompileError: nvcc compilation of /tmp/tmpKjK3Px/kernel.cu 
> failed
> [command: nvcc --cubin -arch sm_20 
> -I/usr/lib/python2.7/dist-packages/pycuda/cuda kernel.cu]
> [stderr:
> /usr/lib/python2.7/dist-packages/pycuda/cuda/pycuda-complex.hpp(553): 
> warning: a __host__ function("pycuda::complex<float>::complex") 
> redeclared with __device__, hence treated as a __host__ __device__ function
>
> kernel.cu(19): error: calling a __host__ function("std::pow<long, long> 
> ") from a __global__ function("pow_method") is not allowed
>
> 1 error detected in the compilation of 
> "/tmp/tmpxft_00000c21_00000000-6_kernel.cpp1.ii".
> ]
>
>
>
> zzz=gpuarray.sum((yyy-xxx)*(yyy-xxx))
>
> works well.

The issue is that you're passing integers. Cast to floating point before
you call the function.

> And another question:
>
> Is there a sqrt-Function?

http://documen.tician.de/pycuda/array.html#pycuda.cumath.sqrt

Andreas

Attachment: pgpimLx7Hchbb.pgp
Description: PGP signature

_______________________________________________
PyCUDA mailing list
PyCUDA@tiker.net
http://lists.tiker.net/listinfo/pycuda

Reply via email to