sru
sru copied to clipboard
AttributeError: 'bytes' object has no attribute 'encode'
Hello,
I got this exception when importing SRU :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tbelos/anaconda3/lib/python3.6/site-packages/sru/__init__.py", line 2, in <module>
from .cuda_functional import *
File "/home/tbelos/anaconda3/lib/python3.6/site-packages/sru/cuda_functional.py", line 355, in <module>
class SRU_Compute_GPU(Function):
File "/home/tbelos/anaconda3/lib/python3.6/site-packages/sru/cuda_functional.py", line 357, in SRU_Compute_GPU
_SRU_PROG = Program(SRU_CODE.encode('utf-8'), 'sru_prog.cu'.encode())
File "/home/tbelos/anaconda3/lib/python3.6/site-packages/pynvrtc/compiler.py", line 52, in __init__
include_names)
File "/home/tbelos/anaconda3/lib/python3.6/site-packages/pynvrtc/interface.py", line 200, in nvrtcCreateProgram
c_char_p(encode_str(src)), c_char_p(encode_str(name)),
File "/home/tbelos/anaconda3/lib/python3.6/site-packages/pynvrtc/interface.py", line 54, in encode_str
return s.encode("utf-8")
AttributeError: 'bytes' object has no attribute 'encode'
Hi,
The new version of pynvrtc
assumes bytes objects instead of str objects as input to Program().
You can fix the error by removing encode('utf-8')
and encode()
call in:
_SRU_PROG = Program(SRU_CODE.encode('utf-8'), 'sru_prog.cu'.encode())