Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module 'encoding._ext.encoding_lib' has no attribute 'Encoding_Float_sum_square_Forward' #44

Closed
mario98 opened this issue May 2, 2018 · 6 comments

Comments

@mario98
Copy link

mario98 commented May 2, 2018

Although compiled successfully (carefully following the instructions), or at least no error messages has been shown during compilation, it seems that the module is not installed correctly.

I get the following error message:


  File "/home/<user>/code/networks/extractors.py", line 259, in forward
    out = self.start_features(x)
  File "/home/<user>/.conda/envs/pytorch-0.3.1-3.5-s/lib/python3.5/site-packages/torch/nn/modules/module.py", line 357, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/<user>/.conda/envs/pytorch-0.3.1-3.5-s/lib/python3.5/site-packages/torch/nn/modules/container.py", line 67, in forward
    input = module(input)
  File "/home/<user>/.conda/envs/pytorch-0.3.1-3.5-s/lib/python3.5/site-packages/torch/nn/modules/module.py", line 357, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/<user>/.conda/envs/pytorch-0.3.1-3.5-s/lib/python3.5/site-packages/encoding/nn/syncbn.py", line 43, in forward
    xsum, xsquare = self.sharedT(sum_square(input.unsqueeze(3)))
  File "/home/<user>/.conda/envs/pytorch-0.3.1-3.5-s/lib/python3.5/site-packages/encoding/functions/syncbn.py", line 59, in sum_square
    return _sum_square.apply(input)
  File "/home/<user>/.conda/envs/pytorch-0.3.1-3.5-s/lib/python3.5/site-packages/encoding/functions/syncbn.py", line 28, in forward
    encoding_lib.Encoding_Float_sum_square_Forward(
AttributeError: module 'encoding._ext.encoding_lib' has no attribute 'Encoding_Float_sum_square_Forward'

extractor.py line 259 refers to extractor.py line 250 from a deep learning repo where I replaced nn.BatchNorm2d with encoding.nn.BatchNorm2d.

Indeed, the folder /home/<user>/.conda/envs/pytorch-0.3.1-3.5-s/lib/python3.5/site-packages/encoding/_ext/encoding_lib does not contain any .py files for me.

What could be the issue here?

I am using:
pytorch 0.3.1 (build from source), I cloned the pytorch repo at state 2b4748011b5881583567bb166801ca6625f2fdda which is associated with the 0.3.1 release. pytorch 0.4 is too unstable and has too many (partly unlisted) breaking changes. I had to revert to v0.3.1
conda 4.3 / cuda 8.0 / Edit: python 3.5

@zhanghang1989
Copy link
Owner

Are you running the script in the repo base folder? Try to run it in different folder.

@mario98
Copy link
Author

mario98 commented May 3, 2018

No, this is not the issue here. I'm running my script from a separate folder, say /home/<user>/code. But thanks for having a look at this. I'll keep you updated when I found something that could be responsible for this issue.
Is it intentional that the folder /home/<user>/.conda/envs/pytorch-0.3.1-3.5-s/lib/python3.5/site-packages/encoding/_ext does not contain any .py files?

@zhanghang1989
Copy link
Owner

something wrong with the installation, there should be __init__.py automatically generated:
_encoding_lib.abi3.so* __init__.py __pycache__/

@mario98
Copy link
Author

mario98 commented May 7, 2018

Ok, strange. It just didn't copy the __init__.py file for some reason. I also couldn't find anything in the log files, Everything seemed to be run though without errors. I tried installation multiple times.

I ended up just copying this file manually from the sources to this directory, this solved the issue.

But now I get:

  [...]
    my_loss.backward()
  File "/home/<user>/.conda/envs/pytorch-0.3.1-3.5-s/lib/python3.5/site-packages/torch/autograd/variable.py", line 167, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph, retain_variables)
  File "/home/<user>/.conda/envs/pytorch-0.3.1-3.5-s/lib/python3.5/site-packages/torch/autograd/__init__.py", line 99, in backward
    variables, grad_variables, retain_graph)
  File "/home/<user>/.conda/envs/pytorch-0.3.1-3.5-s/lib/python3.5/site-packages/torch/autograd/function.py", line 91, in apply
    return self._forward_cls.backward(self, *args)
  File "/home/<user>/.conda/envs/pytorch-0.3.1-3.5-s/lib/python3.5/site-packages/encoding/functions/syncbn.py", line 47, in backward
    gradInput, input.data.view(B, C, -1), gradSum, gradSquare)
  File "/home/<user>/.conda/envs/pytorch-0.3.1-3.5-s/lib/python3.5/site-packages/torch/utils/ffi/__init__.py", line 180, in safe_call
    result = torch._C._safe_call(*args, **kwargs)
TypeError: initializer for ctype 'struct THCudaTensor *' must be a cdata pointer, not Variable

Is this related to my incomplete installation or actually a new bug?

P.S. cffi package version 1.11.5 is installed on my system.

Edit: Solved by changing two lines of code!
It was not related to this issue, it's rather a pytorch 0.3.1 compatibility issue, I opened a new issue report for this.

And finally, the code runs on my machine! Thanks so far for all the helpful comments!

@zhanghang1989
Copy link
Owner

Please checkout the newest version and see if you still have the trouble. See details in PR #51

@zhanghang1989
Copy link
Owner

fixed in PR #59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants