Unknown cuMemcpyDtoH error using a Numba CUDA kernel [closed] - python

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am trying to implement this fairly straightforward function as a CUDA kernel using Numba:
#nb.njit(parallel=True)
def sum_pixel_signals_cpu(pixels_signals, signals, index_map):
for it in nb.prange(signals.shape[0]):
for ipix in nb.prange(signals.shape[1]):
index = index_map[it][ipix]
start_tick = track_starts[it] // consts.t_sampling
for itick in nb.prange(signals.shape[2]):
itime = int(start_tick+itick)
pixels_signals[index, itime] += signals[it][ipix][itick]
This function works fine and the result is what I expect. I tried to implement it a CUDA-equivalent version with this piece of code:
#cuda.jit
def sum_pixel_signals(pixels_signals, signals, index_map):
it, ipix, itick = cuda.grid(3)
if it < signals.shape[0] and ipix < signals.shape[1]:
index = index_map[it][ipix]
start_tick = track_starts[it] // consts.t_sampling
if itick < signals.shape[2]:
itime = int(start_tick+itick)
cuda.atomic.add(pixels_signals, (index, itime), signals[it][ipix][itick])
Unfortunately, when I call the kernel, I get this not very helpful error message:
ERROR:numba.cuda.cudadrv.driver:Call to cuMemcpyDtoH results in UNKNOWN_CUDA_ERROR
---------------------------------------------------------------------------
CudaAPIError Traceback (most recent call last)
<ipython-input-14-3786491325e7> in <module>
----> 1 sum_pixel_signals[threadsperblock,blockspergrid](pixels_signals, d_signals, pixel_index_map)
I don't understand what I am doing wrong. Is there a way to at least debug this kind of error messages?

The problem was caused by the grid arguments written backwards... The correct way:
sum_pixel_signals[blockspergrid,threadsperblock](pixels_signals, d_signals, pixel_index_map)

Related

"TypeError: 'int' object is not subscriptable" in python [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed yesterday.
Improve this question
def get_hidden_card(credit_number, star_count=4):
short_credit_number = str(credit_number[12:16])
return str('*' * star_count + short_credit_number)
print(get_hidden_card(2034399002125581))
As i understand python don't wanna work because he think that str(credit_number[12:16]) is int type, how can i fix it?
The error is:
Traceback (most recent call last):
File "C:\Users\Ivan\PycharmProjects\pythonProject\main.py", line 10, in <module>
print(get_hidden_card(2034399002125581))
File "C:\Users\Ivan\PycharmProjects\pythonProject\main.py", line 4, in get_hidden_card
short_credit_number = str(credit_number[12:16])
TypeError: 'int' object is not subscriptable
Process finished with exit code 1
This is must solve your issue
def get_hidden_card(credit_number, star_count=4):
short_credit_number = str(credit_number)[12:16]
return str('*' * star_count + short_credit_number)
print(get_hidden_card(2034399002125581))

'function' object is not subscriptable in Python [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I've tried to using this code:
def tw_list(text):
tw_list['text'] = tw_list['text'].str.lower()
print('Case Folding Result : \n')
print(tw_list['text'].head(5))
print('\n\n\n')
But when I run it, I get the error:
Case Folding Result :
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-27-c3ee7c744c13> in <module>
6
7 print('Case Folding Result : \n')
----> 8 print(tw_list['texts'].head(5))
9 print('\n\n\n')
TypeError: 'function' object is not subscriptable
i dont know why, can someone help me?
tw_list is the name of your function.
You are trying to access the function as a dict.So it throws error

Inheritance not working as tutorial. what is the problem? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I'm studying 'inheritance' in Pycharm.
I just followed tutorial. And it doesn't work. What's the problem
##Chef.py##
class Chef:
def make_chicken(self):
print("The chef makes a chicken")
def make_salad(self):
print("The chef makes a salad")
def make_special_dish(self):
print("The chef makes bbq ribs")
##another.py##
from Chef import Chef
class another(Chef):
##app.py##
from another import another
a = another()
a.make_salad()
run>>>
error message :
Traceback (most recent call last):
File "C:/Users/NEWS1/PycharmProjects/exc/app.py", line 1, in <module>
from another import another
File "C:\Users\NEWS1\PycharmProjects\exc\another.py", line 9
^
SyntaxError: unexpected EOF while parsing
Process finished with exit code 1
What is the problem....
The issue is in your 'another' class, there's nothing following the colon. You can either add methods to the class or just a 'pass' like so
##another.py##
from Chef import Chef
class another(Chef):
# other content
pass

python numpy round function strange error [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I have the following code from the book python for finance. But the round function from numpy is causing an error like " return round(decimals, out)
TypeError: round() takes at most 2 arguments (3 given)"
anyone knows what I am doing wrong?
import numpy as np
import pandas as pd
import pandas.io.data as web
sp500 = web.DataReader('^GSPC', data_source='yahoo',
start='1/1/2000', end='4/14/2014')
sp500.info()
sp500['Close'].plot(grid=True, figsize=(8, 5))
sp500['42d'] = np.round(pd.rolling_mean(sp500['Close'], window=42), 2)
Based on the error message, it seems that in numpy 1.11.0, the rounding function looks like this:
try:
round = a.round
except AttributeError:
return _wrapit(a, 'round', decimals, out)
return round(decimals, out)
It looks like pandas.Series.round only takes two arguments (self, precision), but numpy is passing it an additional argument, out. Presumably this is either a bug or API change in pandas or numpy.
There are two simple workarounds I can see. The first is to just directly use the Series.round() function:
sp500['42d'] = pd.rolling_mean(sp500['Close'], window=42).round(2)
The other option is to just apply the numpy.round function to the underlying numpy array:
sp500['42d'] = np.round(pd.rolling_mean(sp500['Close'], window=42).values, 2)
Edit: Looks like this is a known issue. See the pandas github tracker, issue #12644.

NameError: global name 'add_to_receives' is not defined | add_to_receives(msg_to) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
def add_to_receivers(receivers): # make sure they are unique
for receiver in receivers:
name, email = receiver
if email not in [u'', None]: # empty receiver pairs are possible
#print email
if email not in msg_receivers and email is not None:
msg_receivers.append(email.lower())
msg_receivers = []
add_to_receives(msg_to)
add_to_receives(msg_cc)
add_to_receives(msg_bcc) # in essence, we don’t care how the message was received
#add_to_receives(msg_delivered_to)
please help me with fixing this error
Traceback (most recent call last):
File "metadata.py", line 309, in worker
add_to_receives(msg_to)
NameError: global name 'add_to_receives' is not defined
full code you can see at http://brage.bibsys.no/xmlui/handle/11250/198551
I think the problem is that the function is called add_to_receiversand you are calling add_to_receives (without the 'r')

Categories

Resources