On Wed, 30 May 2012 22:13:27 +1200, Igor <rychphd(a)gmail.com> wrote:
> Hi Andreas,
> I'm attaching an example for your wiki demonstrating how to find a max
> element position both using ReductionKernel and thrust-nvcc-ctypes.
> The latter doesn't quite work on windows yet. Should work if you're on
> a linux, just change the FOLDER. There is a live version published on
> my sage server (http://dev.math.canterbury.ac.nz/home/pub/26/ ) --
> there all work and show a discouraging 5-fold slowdown of
> ReductionKernel as compared to thrust (run twice, as the .so file is
> loaded lazily?). Could you take a look and edit it if necessary?
Not a fair comparison. The PyCUDA test includes the transfer of the
result to the host. (.get()) Doesn't look like that's the case for
thrust. Also, an 80 MB vector is tiny. At 200 GB/s, that's about 4e-4s,
which is in the vicinity of launch overhead.
Andreas
I have a program that I am running written in PyCuda, that works correctly
the first time I run it. Because I am using a lot of fast little gpuarray
functions, on a TON of different arrays, every time I finish with one I
manually remove it from the memory using array.gpudata.free() so that I
immediately have enough room to do the next array. I do this every time. So
every single array is manually freed. The program will complete
successfully, but if I try to run it a second time, the moment I try to move
anything over to the GPU it says CudaMalloc fail: out of memory.
Any idea what could be causing this? the only way I have found to "fix" it,
is to restart the computer between runs.
--
View this message in context: http://pycuda.2962900.n2.nabble.com/PyCUDA-Memory-error-when-running-progra…
Sent from the PyCuda mailing list archive at Nabble.com.
I'd also be curious to see what the timings are from Python's
perspective, rather than from the GPU's perspective.
- bryan
On Wed, May 30, 2012 at 3:13 AM, Igor <rychphd(a)gmail.com> wrote:
> Hi Andreas,
> I'm attaching an example for your wiki demonstrating how to find a max
> element position both using ReductionKernel and thrust-nvcc-ctypes.
> The latter doesn't quite work on windows yet. Should work if you're on
> a linux, just change the FOLDER. There is a live version published on
> my sage server (http://dev.math.canterbury.ac.nz/home/pub/26/ ) --
> there all work and show a discouraging 5-fold slowdown of
> ReductionKernel as compared to thrust (run twice, as the .so file is
> loaded lazily?). Could you take a look and edit it if necessary?
> Igor
>
> On Fri, May 25, 2012 at 2:55 AM, Andreas Kloeckner
> <kloeckner(a)cims.nyu.edu> wrote:
>> On Thu, 24 May 2012 22:46:16 +1200, Igor <rychphd(a)gmail.com> wrote:
>>> A better programme would be to port all the algorithms and interfaces
>>> of Thrust to PyCUDA. The only reason I need thrust for example, is
>>> that it can find me the extremum element's _location_ which I still
>>> don't know how to do in PyCUDA.
>>
>> Agreed, although thrust's sorting capability won't be matched by PyCUDA
>> in a while. (There's some home for thrust's scan trickeries.)
>>
>> But your specific concern is fortunately already doable. :) It should be
>> fairly easy to modify this test to do what you want. (Simply store the
>> index in the initial 'map' stage.)
>>
>> https://github.com/inducer/pycuda/blob/master/test/test_gpuarray.py#L765
>>
>> Andreas
>>
>> --
>> Andreas Kloeckner
>> Room 1105A (Warren Weaver Hall), Courant Institute, NYU
>> http://www.cims.nyu.edu/~kloeckner/
>> +1-401-648-0599
>
> _______________________________________________
> PyCUDA mailing list
> PyCUDA(a)tiker.net
> http://lists.tiker.net/listinfo/pycuda
>
On Tue, 29 May 2012 18:16:52 -0400, Thomas Wiecki <Thomas_Wiecki(a)brown.edu> wrote:
> Hi,
>
> I saw a couple of times the following idiom being used:
>
> const int tidx = blockIdx.x*blockDim.x + threadIdx.x;
> const int delta = blockDim.x*gridDim.x;
>
> curandState local_state = global_state[tidx];
>
> for (int idx = tidx; idx < n; idx += delta)
> {
> out[idx] = compute_sth(in[idx])
> }
>
> I'm not sure I 100% understand what's going on but it is looping over
> parts of the array spread dt apart. I think however in the case there
> are enough threads available (n < max_threads) only one thread would
> be doing all the work -- is that correct?
>
> Wouldn't a better idiom do sth along the lines of:
>
> for (int idx = tidx; idx < n; idx += max_threads)
>
> thus if n < max_threads it would loop only once per thread and scale
> up seamlessly. Am I missing something?
These two look exactly the same to me, except you called "delta"
"max_threads". I'm really squinting hard, I can't find a difference...
Andreas
Hi Andreas,
I'm attaching an example for your wiki demonstrating how to find a max
element position both using ReductionKernel and thrust-nvcc-ctypes.
The latter doesn't quite work on windows yet. Should work if you're on
a linux, just change the FOLDER. There is a live version published on
my sage server (http://dev.math.canterbury.ac.nz/home/pub/26/ ) --
there all work and show a discouraging 5-fold slowdown of
ReductionKernel as compared to thrust (run twice, as the .so file is
loaded lazily?). Could you take a look and edit it if necessary?
Igor
On Fri, May 25, 2012 at 2:55 AM, Andreas Kloeckner
<kloeckner(a)cims.nyu.edu> wrote:
> On Thu, 24 May 2012 22:46:16 +1200, Igor <rychphd(a)gmail.com> wrote:
>> A better programme would be to port all the algorithms and interfaces
>> of Thrust to PyCUDA. The only reason I need thrust for example, is
>> that it can find me the extremum element's _location_ which I still
>> don't know how to do in PyCUDA.
>
> Agreed, although thrust's sorting capability won't be matched by PyCUDA
> in a while. (There's some home for thrust's scan trickeries.)
>
> But your specific concern is fortunately already doable. :) It should be
> fairly easy to modify this test to do what you want. (Simply store the
> index in the initial 'map' stage.)
>
> https://github.com/inducer/pycuda/blob/master/test/test_gpuarray.py#L765
>
> Andreas
>
> --
> Andreas Kloeckner
> Room 1105A (Warren Weaver Hall), Courant Institute, NYU
> http://www.cims.nyu.edu/~kloeckner/
> +1-401-648-0599
Hi,
I saw a couple of times the following idiom being used:
const int tidx = blockIdx.x*blockDim.x + threadIdx.x;
const int delta = blockDim.x*gridDim.x;
curandState local_state = global_state[tidx];
for (int idx = tidx; idx < n; idx += delta)
{
out[idx] = compute_sth(in[idx])
}
I'm not sure I 100% understand what's going on but it is looping over
parts of the array spread dt apart. I think however in the case there
are enough threads available (n < max_threads) only one thread would
be doing all the work -- is that correct?
Wouldn't a better idiom do sth along the lines of:
for (int idx = tidx; idx < n; idx += max_threads)
thus if n < max_threads it would loop only once per thread and scale
up seamlessly. Am I missing something?
Any advice would be appreciated.
Thomas
The aksetup-defaults.py file is just a bunch of config information -
where is the boost-python library, where are the boost include files,
where is the CUDA compiler, etc. You can update/create it
automatically when installing PyCUDA by using the --update-user (puts
it in ~) or --update-global flags (puts it in /etc) to PyCUDA's
configure.py script. Or you can just copy your siteconf.py file.
- bryan
On Sun, May 27, 2012 at 11:57 AM, Apostolis Glenis
<apostglen46(a)gmail.com> wrote:
> I have no file or folder named ~/.aksetup-defaults.py.
> Maybe it is not installed in the home directory as Thomas suggested in my
> case.
> Maybe it has to do with the fact that I installed codepy with copperhead and
> not as a standalone.
> Maybe Bryan has some extra insight as to what might have happened.
> I will try and fix it as soon as i have more time in my hands.
>
> Thanks for the help anyway.
>
> Apostolis
>
>
> 2012/5/27 Thomas Wiecki <Thomas_Wiecki(a)brown.edu>
>>
>> On Sun, May 27, 2012 at 1:25 PM, Apostolis Glenis <apostglen46(a)gmail.com>
>> wrote:
>> > After google searching i found no -lboost_python-gcc43-mt so I suspect
>> > that
>> > if I change that in the linking command it would work without any
>> > problems.
>> > Did I do anything wrong with the installation of pycuda or codePy? (I
>> > think
>> > that codePy was installed when i installed copperhead).
>> > So I have two questions:
>> > how can I change -lboost_python-gcc43-mt to -lboost_python.
>> > how can I make that the default behaviour.
>>
>> I had the same problem. The reason is that CodePy creates a default
>> string for boost-python (the one you pasted above) if it does not find
>> a config file. I fixed this by copying the site-config.py from the
>> pycuda directory (created by configure.py) to ~/.aksetup-defaults.py
>> which then gets picked up by CodePy to link against the correct
>> boost_python.
>>
>> Also make sure to set USE_SHIPPED_BOOST = False.
>>
>> HTH,
>> Thomas
>>
>> > Apostolis
>> >
>> > 2012/5/27 Apostolis Glenis <apostglen46(a)gmail.com>
>> >>
>> >> I tried to run the example and I got this error:
>> >>
>> >> ---------------------- Host code ----------------------
>> >> #include <boost/python.hpp>
>> >> #include <cuda.h>
>> >> void my_sort(CUdeviceptr input_ptr, int length);
>> >> #include <boost/python/extract.hpp>
>> >> using namespace boost::python;
>> >>
>> >> namespace private_namespace_db9cd38ee0995488b35c8405321b8f95
>> >> {
>> >> object host_entry(object gpu_array)
>> >> {
>> >> tuple shape = extract<tuple>(gpu_array.attr("shape"));
>> >> int length = extract<int>(shape[0]);
>> >> CUdeviceptr ptr = extract<CUdeviceptr>(gpu_array.attr("gpudata"));
>> >> my_sort(ptr, length);
>> >> return gpu_array;
>> >> }
>> >> }
>> >>
>> >> using namespace private_namespace_db9cd38ee0995488b35c8405321b8f95;
>> >>
>> >> BOOST_PYTHON_MODULE(module)
>> >> {
>> >> boost::python::def("host_entry", &host_entry);
>> >> }
>> >> --------------------- Device code ---------------------
>> >> #include <thrust/sort.h>
>> >> #include <thrust/device_vector.h>
>> >> #include <cuda.h>
>> >>
>> >> void my_sort(CUdeviceptr input_ptr, int length)
>> >> {
>> >> thrust::device_ptr<float> thrust_ptr((float*)input_ptr);
>> >> thrust::sort(thrust_ptr, thrust_ptr+length);
>> >> }
>> >> -------------------------------------------------------
>> >> /usr/bin/ld: skipping incompatible /usr/local/cuda/lib/libcudart.so
>> >> when
>> >> searching for -lcudart
>> >> /usr/bin/ld: cannot find -lboost_python-gcc43-mt
>> >> collect2: ld returned 1 exit status
>> >> FAILED compiler invocation: g++ -pthread -fno-strict-aliasing -g -O2 -g
>> >> -fwrapv -O2 -Wall -fPIC -pthread -shared -Wl,-O1
>> >> -Wl,-Bsymbolic-functions
>> >> -Wl,-Bsymbolic-functions -Xlinker -export-dynamic -Wl,-O1
>> >> -Wl,-Bsymbolic-functions -DNDEBUG -I/usr/include/python2.7
>> >> -I/usr/local/cuda/include
>> >>
>> >> /tmp/codepy-compiler-cache-v5-uid1000/207349795ab4e8438bf4fe266c0a7f2c/module.o
>> >>
>> >> /tmp/codepy-compiler-cache-v5-uid1000/cd6dbc7737faf0ddefa740abfda66139/gpu.o
>> >> -L/usr/lib -L/usr/local/cuda/lib -L/usr/local/cuda/lib64 -lcuda
>> >> -lcudart
>> >> -lboost_python-gcc43-mt -lpthread -ldl -lutil -o
>> >>
>> >> /tmp/codepy-compiler-cache-v5-uid1000/207349795ab4e8438bf4fe266c0a7f2c/codepy.temp.207349795ab4e8438bf4fe266c0a7f2c.module.so
>> >> Link error, examine
>> >>
>> >> ['/tmp/codepy-compiler-cache-v5-uid1000/207349795ab4e8438bf4fe266c0a7f2c/module.o',
>> >>
>> >> '/tmp/codepy-compiler-cache-v5-uid1000/cd6dbc7737faf0ddefa740abfda66139/gpu.o'],
>> >> then press [Enter]
>> >> Traceback (most recent call last):
>> >> File "thrust_demo.py", line 85, in <module>
>> >> module = nvcc_mod.compile(gcc_toolchain, nvcc_toolchain,
>> >> debug=False)
>> >> File
>> >>
>> >> "/usr/local/lib/python2.7/dist-packages/codepy-2012.1.2-py2.7.egg/codepy/cuda.py",
>> >> line 104, in compile
>> >> host_mod_name, **kwargs)
>> >> File
>> >>
>> >> "/usr/local/lib/python2.7/dist-packages/codepy-2012.1.2-py2.7.egg/codepy/jit.py",
>> >> line 427, in link_extension
>> >> toolchain.link_extension(destination, objects, debug=debug)
>> >> File
>> >>
>> >> "/usr/local/lib/python2.7/dist-packages/codepy-2012.1.2-py2.7.egg/codepy/toolchain.py",
>> >> line 210, in link_extension
>> >> raise CompileError, "module compilation failed"
>> >> codepy.CompileError: module compilation failed
>> >>
>> >> It seems that there are two errors:
>> >> 1.It tries to link with the 32bit version of cudart, not the 64bit
>> >> 2.It cannot find libboost-python-mt although i have installed the
>> >> package
>> >> libboost and the development files from synaptic.
>> >>
>> >> My OS is ubuntu 11.10 .
>> >>
>> >> What should I do next?
>> >>
>> >> Thank you in advance ,
>> >>
>> >> Apostolis
>> >>
>> >> 2012/5/26 Andreas Kloeckner <lists(a)informa.tiker.net>
>> >>>
>> >>> On Sat, 26 May 2012 14:59:28 -0400, Thomas Wiecki
>> >>> <Thomas_Wiecki(a)brown.edu> wrote:
>> >>> > I tried using the shipped version (bpl_subset) but couldn't get it
>> >>> > to
>> >>> > work somehow (how is one supposed to get the lib files?).
>> >>> >
>> >>> > I now set USE_SHIPPED_BOOST = False and that seems to do the trick
>> >>> > with the ubuntu 11.10 boost packages 1.46.1
>> >>>
>> >>> Right. Should've remembered to say that. There's no way to make codepy
>> >>> work with shipped boost. The reason for this is twofold: a) as you
>> >>> remark, you don't get a libboost-python*, which codepy requires, and
>> >>> even if you got that from elsewhere, b) Boost.Python keeps a global
>> >>> registry of from/to-python converters. Once there are two copies of
>> >>> that
>> >>> registry loaded into a single Python interpreter, things start getting
>> >>> weird. Very weird. :)
>> >>>
>> >>> Andreas
>> >>>
>> >>>
>> >>> _______________________________________________
>> >>> PyCUDA mailing list
>> >>> PyCUDA(a)tiker.net
>> >>> http://lists.tiker.net/listinfo/pycuda
>> >>>
>> >>
>> >
>> >
>> > _______________________________________________
>> > PyCUDA mailing list
>> > PyCUDA(a)tiker.net
>> > http://lists.tiker.net/listinfo/pycuda
>> >
>
>
OK ,i did that and now I get the same error you got in your previous e-mail
(so we are close).
I am attaching you the file.(The original file had a dot before the name as
you said)
I should note that I had to change manually the USE_SHIPPED_BOOST to False.
(I don't know if that played any part).
Thanks again,
Apostolis
2012/5/27 Thomas Wiecki <Thomas_Wiecki(a)brown.edu>
> You'll have to create it by copying it to that place, see my previous
> email:
>
> "I fixed this by copying the site-config.py from the
> pycuda directory (created by configure.py) to ~/.aksetup-defaults.py"
>
> On Sun, May 27, 2012 at 2:57 PM, Apostolis Glenis <apostglen46(a)gmail.com>
> wrote:
> > I have no file or folder named ~/.aksetup-defaults.py.
> > Maybe it is not installed in the home directory as Thomas suggested in my
> > case.
> > Maybe it has to do with the fact that I installed codepy with copperhead
> and
> > not as a standalone.
> > Maybe Bryan has some extra insight as to what might have happened.
> > I will try and fix it as soon as i have more time in my hands.
> >
> > Thanks for the help anyway.
> >
> > Apostolis
> >
> >
> > 2012/5/27 Thomas Wiecki <Thomas_Wiecki(a)brown.edu>
> >>
> >> On Sun, May 27, 2012 at 1:25 PM, Apostolis Glenis <
> apostglen46(a)gmail.com>
> >> wrote:
> >> > After google searching i found no -lboost_python-gcc43-mt so I suspect
> >> > that
> >> > if I change that in the linking command it would work without any
> >> > problems.
> >> > Did I do anything wrong with the installation of pycuda or codePy? (I
> >> > think
> >> > that codePy was installed when i installed copperhead).
> >> > So I have two questions:
> >> > how can I change -lboost_python-gcc43-mt to -lboost_python.
> >> > how can I make that the default behaviour.
> >>
> >> I had the same problem. The reason is that CodePy creates a default
> >> string for boost-python (the one you pasted above) if it does not find
> >> a config file. I fixed this by copying the site-config.py from the
> >> pycuda directory (created by configure.py) to ~/.aksetup-defaults.py
> >> which then gets picked up by CodePy to link against the correct
> >> boost_python.
> >>
> >> Also make sure to set USE_SHIPPED_BOOST = False.
> >>
> >> HTH,
> >> Thomas
> >>
> >> > Apostolis
> >> >
> >> > 2012/5/27 Apostolis Glenis <apostglen46(a)gmail.com>
> >> >>
> >> >> I tried to run the example and I got this error:
> >> >>
> >> >> ---------------------- Host code ----------------------
> >> >> #include <boost/python.hpp>
> >> >> #include <cuda.h>
> >> >> void my_sort(CUdeviceptr input_ptr, int length);
> >> >> #include <boost/python/extract.hpp>
> >> >> using namespace boost::python;
> >> >>
> >> >> namespace private_namespace_db9cd38ee0995488b35c8405321b8f95
> >> >> {
> >> >> object host_entry(object gpu_array)
> >> >> {
> >> >> tuple shape = extract<tuple>(gpu_array.attr("shape"));
> >> >> int length = extract<int>(shape[0]);
> >> >> CUdeviceptr ptr =
> extract<CUdeviceptr>(gpu_array.attr("gpudata"));
> >> >> my_sort(ptr, length);
> >> >> return gpu_array;
> >> >> }
> >> >> }
> >> >>
> >> >> using namespace private_namespace_db9cd38ee0995488b35c8405321b8f95;
> >> >>
> >> >> BOOST_PYTHON_MODULE(module)
> >> >> {
> >> >> boost::python::def("host_entry", &host_entry);
> >> >> }
> >> >> --------------------- Device code ---------------------
> >> >> #include <thrust/sort.h>
> >> >> #include <thrust/device_vector.h>
> >> >> #include <cuda.h>
> >> >>
> >> >> void my_sort(CUdeviceptr input_ptr, int length)
> >> >> {
> >> >> thrust::device_ptr<float> thrust_ptr((float*)input_ptr);
> >> >> thrust::sort(thrust_ptr, thrust_ptr+length);
> >> >> }
> >> >> -------------------------------------------------------
> >> >> /usr/bin/ld: skipping incompatible /usr/local/cuda/lib/libcudart.so
> >> >> when
> >> >> searching for -lcudart
> >> >> /usr/bin/ld: cannot find -lboost_python-gcc43-mt
> >> >> collect2: ld returned 1 exit status
> >> >> FAILED compiler invocation: g++ -pthread -fno-strict-aliasing -g -O2
> -g
> >> >> -fwrapv -O2 -Wall -fPIC -pthread -shared -Wl,-O1
> >> >> -Wl,-Bsymbolic-functions
> >> >> -Wl,-Bsymbolic-functions -Xlinker -export-dynamic -Wl,-O1
> >> >> -Wl,-Bsymbolic-functions -DNDEBUG -I/usr/include/python2.7
> >> >> -I/usr/local/cuda/include
> >> >>
> >> >>
> /tmp/codepy-compiler-cache-v5-uid1000/207349795ab4e8438bf4fe266c0a7f2c/module.o
> >> >>
> >> >>
> /tmp/codepy-compiler-cache-v5-uid1000/cd6dbc7737faf0ddefa740abfda66139/gpu.o
> >> >> -L/usr/lib -L/usr/local/cuda/lib -L/usr/local/cuda/lib64 -lcuda
> >> >> -lcudart
> >> >> -lboost_python-gcc43-mt -lpthread -ldl -lutil -o
> >> >>
> >> >>
> /tmp/codepy-compiler-cache-v5-uid1000/207349795ab4e8438bf4fe266c0a7f2c/
> codepy.temp.207349795ab4e8438bf4fe266c0a7f2c.module.so
> >> >> Link error, examine
> >> >>
> >> >>
> ['/tmp/codepy-compiler-cache-v5-uid1000/207349795ab4e8438bf4fe266c0a7f2c/module.o',
> >> >>
> >> >>
> '/tmp/codepy-compiler-cache-v5-uid1000/cd6dbc7737faf0ddefa740abfda66139/gpu.o'],
> >> >> then press [Enter]
> >> >> Traceback (most recent call last):
> >> >> File "thrust_demo.py", line 85, in <module>
> >> >> module = nvcc_mod.compile(gcc_toolchain, nvcc_toolchain,
> >> >> debug=False)
> >> >> File
> >> >>
> >> >>
> "/usr/local/lib/python2.7/dist-packages/codepy-2012.1.2-py2.7.egg/codepy/cuda.py",
> >> >> line 104, in compile
> >> >> host_mod_name, **kwargs)
> >> >> File
> >> >>
> >> >>
> "/usr/local/lib/python2.7/dist-packages/codepy-2012.1.2-py2.7.egg/codepy/jit.py",
> >> >> line 427, in link_extension
> >> >> toolchain.link_extension(destination, objects, debug=debug)
> >> >> File
> >> >>
> >> >>
> "/usr/local/lib/python2.7/dist-packages/codepy-2012.1.2-py2.7.egg/codepy/toolchain.py",
> >> >> line 210, in link_extension
> >> >> raise CompileError, "module compilation failed"
> >> >> codepy.CompileError: module compilation failed
> >> >>
> >> >> It seems that there are two errors:
> >> >> 1.It tries to link with the 32bit version of cudart, not the 64bit
> >> >> 2.It cannot find libboost-python-mt although i have installed the
> >> >> package
> >> >> libboost and the development files from synaptic.
> >> >>
> >> >> My OS is ubuntu 11.10 .
> >> >>
> >> >> What should I do next?
> >> >>
> >> >> Thank you in advance ,
> >> >>
> >> >> Apostolis
> >> >>
> >> >> 2012/5/26 Andreas Kloeckner <lists(a)informa.tiker.net>
> >> >>>
> >> >>> On Sat, 26 May 2012 14:59:28 -0400, Thomas Wiecki
> >> >>> <Thomas_Wiecki(a)brown.edu> wrote:
> >> >>> > I tried using the shipped version (bpl_subset) but couldn't get it
> >> >>> > to
> >> >>> > work somehow (how is one supposed to get the lib files?).
> >> >>> >
> >> >>> > I now set USE_SHIPPED_BOOST = False and that seems to do the trick
> >> >>> > with the ubuntu 11.10 boost packages 1.46.1
> >> >>>
> >> >>> Right. Should've remembered to say that. There's no way to make
> codepy
> >> >>> work with shipped boost. The reason for this is twofold: a) as you
> >> >>> remark, you don't get a libboost-python*, which codepy requires, and
> >> >>> even if you got that from elsewhere, b) Boost.Python keeps a global
> >> >>> registry of from/to-python converters. Once there are two copies of
> >> >>> that
> >> >>> registry loaded into a single Python interpreter, things start
> getting
> >> >>> weird. Very weird. :)
> >> >>>
> >> >>> Andreas
> >> >>>
> >> >>>
> >> >>> _______________________________________________
> >> >>> PyCUDA mailing list
> >> >>> PyCUDA(a)tiker.net
> >> >>> http://lists.tiker.net/listinfo/pycuda
> >> >>>
> >> >>
> >> >
> >> >
> >> > _______________________________________________
> >> > PyCUDA mailing list
> >> > PyCUDA(a)tiker.net
> >> > http://lists.tiker.net/listinfo/pycuda
> >> >
> >
> >
>
You'll have to create it by copying it to that place, see my previous email:
"I fixed this by copying the site-config.py from the
pycuda directory (created by configure.py) to ~/.aksetup-defaults.py"
On Sun, May 27, 2012 at 2:57 PM, Apostolis Glenis <apostglen46(a)gmail.com> wrote:
> I have no file or folder named ~/.aksetup-defaults.py.
> Maybe it is not installed in the home directory as Thomas suggested in my
> case.
> Maybe it has to do with the fact that I installed codepy with copperhead and
> not as a standalone.
> Maybe Bryan has some extra insight as to what might have happened.
> I will try and fix it as soon as i have more time in my hands.
>
> Thanks for the help anyway.
>
> Apostolis
>
>
> 2012/5/27 Thomas Wiecki <Thomas_Wiecki(a)brown.edu>
>>
>> On Sun, May 27, 2012 at 1:25 PM, Apostolis Glenis <apostglen46(a)gmail.com>
>> wrote:
>> > After google searching i found no -lboost_python-gcc43-mt so I suspect
>> > that
>> > if I change that in the linking command it would work without any
>> > problems.
>> > Did I do anything wrong with the installation of pycuda or codePy? (I
>> > think
>> > that codePy was installed when i installed copperhead).
>> > So I have two questions:
>> > how can I change -lboost_python-gcc43-mt to -lboost_python.
>> > how can I make that the default behaviour.
>>
>> I had the same problem. The reason is that CodePy creates a default
>> string for boost-python (the one you pasted above) if it does not find
>> a config file. I fixed this by copying the site-config.py from the
>> pycuda directory (created by configure.py) to ~/.aksetup-defaults.py
>> which then gets picked up by CodePy to link against the correct
>> boost_python.
>>
>> Also make sure to set USE_SHIPPED_BOOST = False.
>>
>> HTH,
>> Thomas
>>
>> > Apostolis
>> >
>> > 2012/5/27 Apostolis Glenis <apostglen46(a)gmail.com>
>> >>
>> >> I tried to run the example and I got this error:
>> >>
>> >> ---------------------- Host code ----------------------
>> >> #include <boost/python.hpp>
>> >> #include <cuda.h>
>> >> void my_sort(CUdeviceptr input_ptr, int length);
>> >> #include <boost/python/extract.hpp>
>> >> using namespace boost::python;
>> >>
>> >> namespace private_namespace_db9cd38ee0995488b35c8405321b8f95
>> >> {
>> >> object host_entry(object gpu_array)
>> >> {
>> >> tuple shape = extract<tuple>(gpu_array.attr("shape"));
>> >> int length = extract<int>(shape[0]);
>> >> CUdeviceptr ptr = extract<CUdeviceptr>(gpu_array.attr("gpudata"));
>> >> my_sort(ptr, length);
>> >> return gpu_array;
>> >> }
>> >> }
>> >>
>> >> using namespace private_namespace_db9cd38ee0995488b35c8405321b8f95;
>> >>
>> >> BOOST_PYTHON_MODULE(module)
>> >> {
>> >> boost::python::def("host_entry", &host_entry);
>> >> }
>> >> --------------------- Device code ---------------------
>> >> #include <thrust/sort.h>
>> >> #include <thrust/device_vector.h>
>> >> #include <cuda.h>
>> >>
>> >> void my_sort(CUdeviceptr input_ptr, int length)
>> >> {
>> >> thrust::device_ptr<float> thrust_ptr((float*)input_ptr);
>> >> thrust::sort(thrust_ptr, thrust_ptr+length);
>> >> }
>> >> -------------------------------------------------------
>> >> /usr/bin/ld: skipping incompatible /usr/local/cuda/lib/libcudart.so
>> >> when
>> >> searching for -lcudart
>> >> /usr/bin/ld: cannot find -lboost_python-gcc43-mt
>> >> collect2: ld returned 1 exit status
>> >> FAILED compiler invocation: g++ -pthread -fno-strict-aliasing -g -O2 -g
>> >> -fwrapv -O2 -Wall -fPIC -pthread -shared -Wl,-O1
>> >> -Wl,-Bsymbolic-functions
>> >> -Wl,-Bsymbolic-functions -Xlinker -export-dynamic -Wl,-O1
>> >> -Wl,-Bsymbolic-functions -DNDEBUG -I/usr/include/python2.7
>> >> -I/usr/local/cuda/include
>> >>
>> >> /tmp/codepy-compiler-cache-v5-uid1000/207349795ab4e8438bf4fe266c0a7f2c/module.o
>> >>
>> >> /tmp/codepy-compiler-cache-v5-uid1000/cd6dbc7737faf0ddefa740abfda66139/gpu.o
>> >> -L/usr/lib -L/usr/local/cuda/lib -L/usr/local/cuda/lib64 -lcuda
>> >> -lcudart
>> >> -lboost_python-gcc43-mt -lpthread -ldl -lutil -o
>> >>
>> >> /tmp/codepy-compiler-cache-v5-uid1000/207349795ab4e8438bf4fe266c0a7f2c/codepy.temp.207349795ab4e8438bf4fe266c0a7f2c.module.so
>> >> Link error, examine
>> >>
>> >> ['/tmp/codepy-compiler-cache-v5-uid1000/207349795ab4e8438bf4fe266c0a7f2c/module.o',
>> >>
>> >> '/tmp/codepy-compiler-cache-v5-uid1000/cd6dbc7737faf0ddefa740abfda66139/gpu.o'],
>> >> then press [Enter]
>> >> Traceback (most recent call last):
>> >> File "thrust_demo.py", line 85, in <module>
>> >> module = nvcc_mod.compile(gcc_toolchain, nvcc_toolchain,
>> >> debug=False)
>> >> File
>> >>
>> >> "/usr/local/lib/python2.7/dist-packages/codepy-2012.1.2-py2.7.egg/codepy/cuda.py",
>> >> line 104, in compile
>> >> host_mod_name, **kwargs)
>> >> File
>> >>
>> >> "/usr/local/lib/python2.7/dist-packages/codepy-2012.1.2-py2.7.egg/codepy/jit.py",
>> >> line 427, in link_extension
>> >> toolchain.link_extension(destination, objects, debug=debug)
>> >> File
>> >>
>> >> "/usr/local/lib/python2.7/dist-packages/codepy-2012.1.2-py2.7.egg/codepy/toolchain.py",
>> >> line 210, in link_extension
>> >> raise CompileError, "module compilation failed"
>> >> codepy.CompileError: module compilation failed
>> >>
>> >> It seems that there are two errors:
>> >> 1.It tries to link with the 32bit version of cudart, not the 64bit
>> >> 2.It cannot find libboost-python-mt although i have installed the
>> >> package
>> >> libboost and the development files from synaptic.
>> >>
>> >> My OS is ubuntu 11.10 .
>> >>
>> >> What should I do next?
>> >>
>> >> Thank you in advance ,
>> >>
>> >> Apostolis
>> >>
>> >> 2012/5/26 Andreas Kloeckner <lists(a)informa.tiker.net>
>> >>>
>> >>> On Sat, 26 May 2012 14:59:28 -0400, Thomas Wiecki
>> >>> <Thomas_Wiecki(a)brown.edu> wrote:
>> >>> > I tried using the shipped version (bpl_subset) but couldn't get it
>> >>> > to
>> >>> > work somehow (how is one supposed to get the lib files?).
>> >>> >
>> >>> > I now set USE_SHIPPED_BOOST = False and that seems to do the trick
>> >>> > with the ubuntu 11.10 boost packages 1.46.1
>> >>>
>> >>> Right. Should've remembered to say that. There's no way to make codepy
>> >>> work with shipped boost. The reason for this is twofold: a) as you
>> >>> remark, you don't get a libboost-python*, which codepy requires, and
>> >>> even if you got that from elsewhere, b) Boost.Python keeps a global
>> >>> registry of from/to-python converters. Once there are two copies of
>> >>> that
>> >>> registry loaded into a single Python interpreter, things start getting
>> >>> weird. Very weird. :)
>> >>>
>> >>> Andreas
>> >>>
>> >>>
>> >>> _______________________________________________
>> >>> PyCUDA mailing list
>> >>> PyCUDA(a)tiker.net
>> >>> http://lists.tiker.net/listinfo/pycuda
>> >>>
>> >>
>> >
>> >
>> > _______________________________________________
>> > PyCUDA mailing list
>> > PyCUDA(a)tiker.net
>> > http://lists.tiker.net/listinfo/pycuda
>> >
>
>