0

I have written the code below in order to discover the number of threads and blocks and send them to train_kernel function.

rows = df.shape[0]
thread_ct = (gpu.WARP_SIZE, gpu.WARP_SIZE)
block_ct = map(lambda x: int(math.ceil(float(x) / thread_ct[0])),[rows,ndims])
train_kernel[block_ct, thread_ct](Xg, yg, syn0g, syn1g, iterations)

but after execution, I face the error below:

griddim must be a sequence of integers

talonmies
  • 70,661
  • 34
  • 192
  • 269
AmirAli
  • 9
  • 4

1 Answers1

1

Although you have not stated it, you are clearly running this code in Python 3.

The semantics of map changed between Python 2 and Python 3. In Python 2 map returns a list. In Python 3 it returns an iterator. See here.

To fix this you need to do something like:

block_ct = list(map(lambda x: int(math.ceil(float(x) / thread_ct[0])),[rows,ndims]))

Alternatively you could just use a list comprehension without the lambda expression and map call:

block_ct = [ int(math.ceil(float(x) / thread_ct[0])) for x in [rows,ndims] ]

Either will yield a list with the necessary elements which should work in the CUDA kernel launch call.

talonmies
  • 70,661
  • 34
  • 192
  • 269