Hi,
I am trying to extend the sample code for 2D rotation from
https://wiki.tiker.net/PyCuda/Examples/Rotate to 3D. Equation #2 on
http://mathworld.wolfram.com/RotationMatrix.html represents the sample
implementation, I implemented equations #3, #4 and #5 to make it work with
3D data. Here is summary what I tried so far:
- Set 'texture<float, 3> tex;'
- I am not sure about the offset, I put it as 'int didx = z*newih*newid + y
* newiw + x;'
- Changed all text2D for text3D
- The original code uses: 'cuda.matrix_to_texref(a, texref, order="C")' to
generate the 2D cuda texture, but as I want to work with 3D data, this
method does not work. I checked that matrix_to_texref calls the function
matrix_to_array that is explicitly implemented for 2D as you can see here:
'h, w = matrix.shape'. I tried to adapt the code to 3D:
def matrix3D_to_texref(matrix, texref, order):
bind_array_to_texref(matrix3D_to_array(matrix, order), texref)
def matrix3D_to_array(matrix, order, allow_double_hack=False):
if order.upper() == "C":
d, h, w = matrix.shape#TODO: I am not sure about this, it was
previously without 'd', now it should work with 3D data
stride = 0
elif order.upper() == "F":
d, w, h = matrix.shape
stride = -1
else:
raise LogicError("order must be either F or C")
matrix = np.asarray(matrix, order=order)
descr = ArrayDescriptor3D()#TODO: I am not sure about this, it was
previously ArrayDescriptor()
descr.width = w
descr.height = h
descr.depth = d #TODO: I am not sure about this, this was not there
previously
if matrix.dtype == np.float64 and allow_double_hack:
descr.format = array_format.SIGNED_INT32
descr.num_channels = 3
else:
descr.format = dtype_to_array_format(matrix.dtype)
descr.num_channels = 1
ary = Array(descr)
copy = Memcpy3D() #TODO: I am not sure about this, originally it was
Memcpy2D()
copy.set_src_host(matrix)
copy.set_dst_array(ary)
copy.width_in_bytes = copy.src_pitch = copy.dst_pitch = \
matrix.strides[stride]
copy.height = h
copy.depth = d #TODO: I am not sure about this, this was not there
previously
copy(aligned=True)
return ary
Is there another way to generate a 3D pycuda texture? Or maybe I am close to
fix the issue, for now I am getting the following error:
Boost.Python.ArgumentError: Python argument types in
Memcpy3D.__call__(Memcpy3D)
did not match C++ signature:
__call__(struct pycuda::memcpy_3d {lvalue}, class pycuda::stream)
__call__(struct pycuda::memcpy_3d {lvalue})
Best regards,
Gabriel
--
View this message in context: http://pycuda.2962900.n2.nabble.com/3D-rotation-on-PyCuda-tp7575825.html
Sent from the PyCuda mailing list archive at Nabble.com.
Baskaran,
Baskaran Sankaran <baskarans(a)gmail.com> writes:
> I am having hard time installing PyCUDA with cuda-9.0 on rhel7.
Thanks for the report. CUDA 9 support was added to git a while back but
was not yet part of a release. I've just released 2017.1.1 that should
address (at least some of) the issues you ran into.
Best,
Andreas
Hi everyone,
I am having hard time installing PyCUDA with cuda-9.0 on rhel7.
I tried both pip install as well as from source and in both cases. Here is
the command I used when building from source. I suspect it has something to
do with wrap_cudadrv.cpp (see the error messages below), though I am not
sure what. Any help will be much appreciated.
$ cd pycuda-2017.1
$ ./configure.py --cuda-root=/usr/local/cuda-9.0
--cudadrv-lib-dir=/usr/lib64/nvidia --boost-inc-dir=/usr/include
--boost-lib-dir=/usr/lib64 --boost-python-libname=boost_python
--boost-thread-libname=boost_thread
$ python setup.py build
Here is my setup:
RHEL-7
gcc (GCC) 4.8.5 20150623
cuda-9.0
I get the following cryptic message in the end:
error: command 'gcc' failed with exit status 1
And, here is some more snippet before the setup.py fails.
src/wrapper/wrap_cudadrv.cpp:669:83: warning: deprecated conversion from
string constant to ‘char*’ [-Wwrite-strings]
Cuda##NAME = py::handle<>(PyErr_NewException("pycuda._driver." #NAME,
BASE, NULL)); \
^
src/wrapper/wrap_cudadrv.cpp:674:5: note: in expansion of macro
‘DECLARE_EXC’
DECLARE_EXC(MemoryError, CudaError.get());
^
src/wrapper/wrap_cudadrv.cpp:669:83: warning: deprecated conversion from
string constant to ‘char*’ [-Wwrite-strings]
Cuda##NAME = py::handle<>(PyErr_NewException("pycuda._driver." #NAME,
BASE, NULL)); \
^
src/wrapper/wrap_cudadrv.cpp:675:5: note: in expansion of macro
‘DECLARE_EXC’
DECLARE_EXC(LogicError, CudaError.get());
^
src/wrapper/wrap_cudadrv.cpp:669:83: warning: deprecated conversion from
string constant to ‘char*’ [-Wwrite-strings]
Cuda##NAME = py::handle<>(PyErr_NewException("pycuda._driver." #NAME,
BASE, NULL)); \
^
src/wrapper/wrap_cudadrv.cpp:676:5: note: in expansion of macro
‘DECLARE_EXC’
DECLARE_EXC(LaunchError, CudaError.get());
^
src/wrapper/wrap_cudadrv.cpp:669:83: warning: deprecated conversion from
string constant to ‘char*’ [-Wwrite-strings]
Cuda##NAME = py::handle<>(PyErr_NewException("pycuda._driver." #NAME,
BASE, NULL)); \
^
src/wrapper/wrap_cudadrv.cpp:677:5: note: in expansion of macro
‘DECLARE_EXC’
DECLARE_EXC(RuntimeError, CudaError.get());
src/wrapper/wrap_cudadrv.cpp:978:26: error: ‘CU_TARGET_COMPUTE_10’ was not
declared in this scope
.value("COMPUTE_10", CU_TARGET_COMPUTE_10)
^
src/wrapper/wrap_cudadrv.cpp:979:26: error: ‘CU_TARGET_COMPUTE_11’ was not
declared in this scope
.value("COMPUTE_11", CU_TARGET_COMPUTE_11)
^
src/wrapper/wrap_cudadrv.cpp:980:26: error: ‘CU_TARGET_COMPUTE_12’ was not
declared in this scope
.value("COMPUTE_12", CU_TARGET_COMPUTE_12)
^
src/wrapper/wrap_cudadrv.cpp:981:26: error: ‘CU_TARGET_COMPUTE_13’ was not
declared in this scope
.value("COMPUTE_13", CU_TARGET_COMPUTE_13)
^
In file included from
bpl-subset/bpl_subset/boost/system/system_error.hpp:14:0,
from bpl-subset/bpl_subset/boost/thread/exceptions.hpp:22,
from
bpl-subset/bpl_subset/boost/thread/pthread/thread_data.hpp:10,
from bpl-subset/bpl_subset/boost/thread/thread.hpp:17,
from src/cpp/cuda.hpp:37,
from src/wrapper/wrap_cudadrv.cpp:1:
bpl-subset/bpl_subset/boost/system/error_code.hpp: At global scope:
bpl-subset/bpl_subset/boost/system/error_code.hpp:214:36: warning:
‘pycudaboost::system::posix_category’ defined but not used
[-Wunused-variable]
static const error_category & posix_category = generic_category();
^
bpl-subset/bpl_subset/boost/system/error_code.hpp:215:36: warning:
‘pycudaboost::system::errno_ecat’ defined but not used [-Wunused-variable]
static const error_category & errno_ecat = generic_category();
^
bpl-subset/bpl_subset/boost/system/error_code.hpp:216:36: warning:
‘pycudaboost::system::native_ecat’ defined but not used [-Wunused-variable]
static const error_category & native_ecat = system_category();
^
error: command 'gcc' failed with exit status 1
Thanks
- Baskaran