Hi,
I know got example code:
import pickle
import numpy
import pylab
import pycuda.autoinit
import pycuda.driver as cuda
import pycuda.reduction
from pycuda.compiler import SourceModule
mod = SourceModule("""
__global__ void threshold(float** a, float th)
{
int x = (blockDim.x * blockIdx.x) + threadIdx.x;
int y = (blockDim.y * blockIdx.y) + threadIdx.y;
if (a[x][y] < th)
a[x][y] = 0;
}
""")
#Calibration
class saveit:
pass
save=saveit()
save.name = x_%06d.pickle'
save.count = 0
i = 10
im=pickle.load(open(save.name%i))
im[numpy.isnan(im)] = 0
##host code, provides gt
im1 = im.copy()
fTh = 1000.
im1[ im1 < fTh ] = 0.
im = im.astype( 'float32' )
print im.shape
a_gpu = cuda.mem_alloc(im.nbytes)
cuda.memcpy_htod(a_gpu, im)
## execute kernel
func = mod.get_function("threshold")
## im has shape (480, 640)
func( a_gpu, numpy.float32(fTh), block=(16,16,1), grid=(30,40) )
## copy result
res = numpy.zeros_like( im, 'float32' )
cuda.memcpy_dtoh( res, a_gpu )
## visualize result
pylab.imshow( res )
pylab.title( 'dev code' )
pylab.show()
pylab.figure()
pylab.imshow( im1 )
pylab.title( 'gt' )
pylab.show()
##done
Result:
D:\Test>test_image_cuda.py
(480, 640)
Traceback (most recent call last):
File "D:\Test\test_image_cuda.py", line 61, in <module>
cuda.memcpy_dtoh( res, a_gpu )
pycuda._driver.Error: cuMemcpyDtoH failed: unknown PyCUDA WARNING: a clean-up
operation failed (dead context maybe?) cuMemFree failed: unknown PyCUDA
WARNING: a clean-up operation failed (dead context maybe?) cuModuleUnload
failed: unknown
(line numbers to not correspond)
Any suggestions?
--
Georg Teichtmeister
Scientist
Machine Vision Applications
DIGITAL - Institute of Information and Communication Technologies
JOANNEUM RESEARCH
Steyrergasse 17
8010 Graz
phone: +43 316 876 1778
fax: +43 316 876 1720
-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im Auftrag von
Teichtmeister, Georg
Gesendet: Freitag, 16. März 2012 13:36
An: ([email protected])
Betreff: [PyCUDA] Compatibility question
Hi,
We are using the pre-compiled version pycuda-2011.2.2.win32-py2.7.exe by
Christoph Golke with CUDA SDK 4.2.18 and Pythonxy 2.7.7.2 on a Windows 7 64bit
machine. The CUDA SDK is 32bit, the driver obviously 64bit (because of
Windows). HW: Intel Core i7-2600, 560Ti 2GB, 8GB RAM
Questions:
-> Is this generally a clever idea?
-> Could the error using cuMemcpyHtoD described below be related to this?
When we are running some code, cuMemcpyDtoH fails with an unknown error.
>> Pycuda._driver.Error: cuMemcpyDtoH failed: unknown
I am sorry for this kind of superficial description, but we are new to this
code (which was created by an ex-employee) and we are trying to get into pycuda
and also try to reproduce the error on a simpler code right at the moment.
However, it would be of great help, if one of you could tell us, that the setup
described above is completely insane, and we can concentrate on the right steps
instead of walking in the dark.
Kind regards,
Georg
--
Georg Teichtmeister
Scientist
Machine Vision Applications
DIGITAL - Institute of Information and Communication Technologies JOANNEUM
RESEARCH
Steyrergasse 17
8010 Graz
phone: +43 316 876 1778
fax: +43 316 876 1720
_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda
_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda