This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 193
AttributeError: 'bytes' object has no attribute 'encode' #26
Comments
this is a result of this issue with pynvrtc: |
n2cholas
added a commit
to n2cholas/pytorch-qrnn
that referenced
this issue
Jan 5, 2020
The new version of pynvrtc expects bytes instead of a string, so it's not possible to call `.encode()` for the `Program` inputs. based on salesforce#26
I did that change and now I get a different error:
I am installing the latest master of qrnn via
|
Hey @delip , I got it working by also removing kernel.encode in line 102. |
Yeah I removed both |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
AttributeError Traceback (most recent call last)
in
49 model.train()
50 optimizer.zero_grad()
---> 51 classes = model(data)
52 loss = focal_loss(classes, focal_label) + margin_loss(classes, margin_label)
53 loss.backward()
~/.local/lib/python3.6/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
487 result = self._slow_forward(*input, **kwargs)
488 else:
--> 489 result = self.forward(*input, **kwargs)
490 for hook in self._forward_hooks.values():
491 hook_result = hook(self, input, result)
in forward(self, batch)
63 # x = torch.nn.utils.rnn.pack_padded_sequence(x, lengths)
64 # self.rnn.flatten_parameters()
---> 65 x, _ = self.rnn(x)
66 # x, _ = torch.nn.utils.rnn.pad_packed_sequence(x)
67 x = self.dropout(x)
~/.local/lib/python3.6/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
487 result = self._slow_forward(*input, **kwargs)
488 else:
--> 489 result = self.forward(*input, **kwargs)
490 for hook in self._forward_hooks.values():
491 hook_result = hook(self, input, result)
~/.local/lib/python3.6/site-packages/torchqrnn/qrnn.py in forward(self, input, hidden)
162
163 for i, layer in enumerate(self.layers):
--> 164 input, hn = layer(input, None if hidden is None else hidden[i])
165 next_hidden.append(hn)
166
~/.local/lib/python3.6/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
487 result = self._slow_forward(*input, **kwargs)
488 else:
--> 489 result = self.forward(*input, **kwargs)
490 for hook in self._forward_hooks.values():
491 hook_result = hook(self, input, result)
~/.local/lib/python3.6/site-packages/torchqrnn/qrnn.py in forward(self, X, hidden)
97 # Forget Mult
98 # For testing QRNN without ForgetMult CUDA kernel, C = Z * F may be useful
---> 99 C = ForgetMult()(F, Z, hidden, use_cuda=self.use_cuda)
100
101 # Apply (potentially optional) output gate
~/.local/lib/python3.6/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
487 result = self._slow_forward(*input, **kwargs)
488 else:
--> 489 result = self.forward(*input, **kwargs)
490 for hook in self._forward_hooks.values():
491 hook_result = hook(self, input, result)
~/.local/lib/python3.6/site-packages/torchqrnn/forget_mult.py in forward(self, f, x, hidden_init, use_cuda)
176 ###
177 # Avoiding 'RuntimeError: expected a Variable argument, but got NoneType' when hidden_init is None
--> 178 if hidden_init is None: return GPUForgetMult()(f, x) if use_cuda else CPUForgetMult()(f, x)
179 return GPUForgetMult()(f, x, hidden_init) if use_cuda else CPUForgetMult()(f, x, hidden_init)
180
~/.local/lib/python3.6/site-packages/torchqrnn/forget_mult.py in forward(self, f, x, hidden_init)
118
119 def forward(self, f, x, hidden_init=None):
--> 120 self.compile()
121 seq_size, batch_size, hidden_size = f.size()
122 result = f.new(seq_size + 1, batch_size, hidden_size)
~/.local/lib/python3.6/site-packages/torchqrnn/forget_mult.py in compile(self)
100 def compile(self):
101 if self.ptx is None:
--> 102 program = Program(kernel.encode(), 'recurrent_forget_mult.cu'.encode())
103 GPUForgetMult.ptx = program.compile()
104
~/.local/lib/python3.6/site-packages/pynvrtc/compiler.py in init(self, src, name, headers, include_names, lib_name)
50 self._program = self._interface.nvrtcCreateProgram(src, name,
51 headers,
---> 52 include_names)
53
54 def del(self):
~/.local/lib/python3.6/site-packages/pynvrtc/interface.py in nvrtcCreateProgram(self, src, name, headers, include_names)
198 include_names_array[:] = encode_str_list(include_names)
199 code = self._lib.nvrtcCreateProgram(byref(res),
--> 200 c_char_p(encode_str(src)), c_char_p(encode_str(name)),
201 len(headers),
202 headers_array, include_names_array)
~/.local/lib/python3.6/site-packages/pynvrtc/interface.py in encode_str(s)
52 if is_python2:
53 return s
---> 54 return s.encode("utf-8")
55
56
AttributeError: 'bytes' object has no attribute 'encode'
The text was updated successfully, but these errors were encountered: