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

Cannot import encoding #70

Open
OasisYang opened this issue Jun 13, 2018 · 32 comments
Open

Cannot import encoding #70

OasisYang opened this issue Jun 13, 2018 · 32 comments

Comments

@OasisYang
Copy link

Hi, I can run "python setup.py install" with no errors, but when i try to "import encoding". I got the error like this. Could you help me with that, thanks.
image

@zhanghang1989
Copy link
Owner

Please install ninja 1.8.2 by following the instructions https://www.claudiokuenzler.com/blog/756/install-newer-ninja-build-tools-ubuntu-14.04-trusty#.WxYrvFMvzJw

@OasisYang
Copy link
Author

I installed the ninja 1.8.2 by the instructions you mentioned, but got the same error @zhanghang1989.

@liyingying05
Copy link

I have got the same error, and I changed ['ninja', '-v'] to ['ninja', '--v'],but the main error also exists, when I try "import encoding", I got error " ImportError: No module named 'enclib_cpu' ", it seems must have one of this
image
but I have none.
I have run "python setup.py install" with no errors and my ninja version is 1.8.2.
@zhanghang1989 @OasisYang Have you solved it?

@zhanghang1989
Copy link
Owner

Are you using the PyTorch master branch?

@vribeiro1
Copy link

@zhanghang1989 I am having the same issues described above. At first I had the RuntimeError: Error building extension 'enclib_cpu' just like @OasisYang described. Then I tried replacing ['ninja', '-v'] by ['ninja', '--v'] like @liyingying05 did, and also had the ImportError: No module named 'enclib_cpu'.

I have ninja 1.8.2 installed. I pip-installed torch-encoding with no errors. Also tried installing via setup.py, which worked fine. I'm working on the Pytorch master branch. Do any of you have solved it?

@liyingying05
Copy link

liyingying05 commented Jul 5, 2018

@vribeiro1 I have solved it using the PyTorch master branch, and the ['ninja', '-v'] should not be changed.

@XindyTT
Copy link

XindyTT commented Jul 23, 2018

I have successful installed pytorch 0.5 and ninja 1.8.2,however when I import encoding, there has also problems.

`Traceback (most recent call last):
File "/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 742, in _build_extension_module
['ninja', '-v'], stderr=subprocess.STDOUT, cwd=build_directory)
File "/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/subprocess.py", line 376, in check_output
**kwargs).stdout
File "/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/subprocess.py", line 468, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/init.py", line 13, in
from . import nn, functions, dilated, parallel, utils, models, datasets
File "/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/nn/init.py", line 12, in
from .encoding import *
File "/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/nn/encoding.py", line 18, in
from ..functions import scaledL2, aggregate, pairwise_cosine
File "/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/functions/init.py", line 2, in
from .encoding import *
File "/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/functions/encoding.py", line 14, in
from .. import lib
File "/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/init.py", line 20, in
], build_directory=gpu_path, verbose=False)
File "/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 496, in load
with_cuda=with_cuda)
File "/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 664, in _jit_compile
_build_extension_module(name, build_directory)
File "/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 748, in _build_extension_module
name, error.output.decode()))
RuntimeError: Error building extension 'enclib_gpu': [1/4] /usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=enclib_gpu -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include/TH -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/home/wuxinting/anaconda3/envs/pytorch-master/include/python3.7m --compiler-options '-fPIC' -std=c++11 -c /home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/encoding_kernel.cu -o encoding_kernel.cuda.o
FAILED: encoding_kernel.cuda.o
/usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=enclib_gpu -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include/TH -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/home/wuxinting/anaconda3/envs/pytorch-master/include/python3.7m --compiler-options '-fPIC' -std=c++11 -c /home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/encoding_kernel.cu -o encoding_kernel.cuda.o
/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/encoding_kernel.cu(315): error: class "at::Context" has no member "getCurrentCUDAStream"

/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/encoding_kernel.cu(341): error: class "at::Context" has no member "getCurrentCUDAStream"

/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/encoding_kernel.cu(364): error: class "at::Context" has no member "getCurrentCUDAStream"

/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/encoding_kernel.cu(391): error: class "at::Context" has no member "getCurrentCUDAStream"

4 errors detected in the compilation of "/tmp/tmpxft_00005f49_00000000-6_encoding_kernel.cpp1.ii".
[2/4] /usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=enclib_gpu -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include/TH -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/home/wuxinting/anaconda3/envs/pytorch-master/include/python3.7m --compiler-options '-fPIC' -std=c++11 -c /home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/syncbn_kernel.cu -o syncbn_kernel.cuda.o
FAILED: syncbn_kernel.cuda.o
/usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=enclib_gpu -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include/TH -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/home/wuxinting/anaconda3/envs/pytorch-master/include/python3.7m --compiler-options '-fPIC' -std=c++11 -c /home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/syncbn_kernel.cu -o syncbn_kernel.cuda.o
/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/syncbn_kernel.cu(183): error: class "at::Context" has no member "getCurrentCUDAStream"

/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/syncbn_kernel.cu(217): error: class "at::Context" has no member "getCurrentCUDAStream"

/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/syncbn_kernel.cu(249): error: class "at::Context" has no member "getCurrentCUDAStream"

/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/syncbn_kernel.cu(272): error: class "at::Context" has no member "getCurrentCUDAStream"

4 errors detected in the compilation of "/tmp/tmpxft_00005f4a_00000000-6_syncbn_kernel.cpp1.ii".
[3/4] /usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=enclib_gpu -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include/TH -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/home/wuxinting/anaconda3/envs/pytorch-master/include/python3.7m --compiler-options '-fPIC' -std=c++11 -c /home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/roi_align_kernel.cu -o roi_align_kernel.cuda.o
FAILED: roi_align_kernel.cuda.o
/usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=enclib_gpu -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include/TH -I/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/home/wuxinting/anaconda3/envs/pytorch-master/include/python3.7m --compiler-options '-fPIC' -std=c++11 -c /home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/roi_align_kernel.cu -o roi_align_kernel.cuda.o
/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/roi_align_kernel.cu(373): error: class "at::Context" has no member "getCurrentCUDAStream"

/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/roi_align_kernel.cu(373): error: class "at::Context" has no member "getCurrentCUDAStream"

/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/roi_align_kernel.cu(420): error: class "at::Context" has no member "getCurrentCUDAStream"

/home/wuxinting/anaconda3/envs/pytorch-master/lib/python3.7/site-packages/encoding/lib/gpu/roi_align_kernel.cu(420): error: class "at::Context" has no member "getCurrentCUDAStream"

4 errors detected in the compilation of "/tmp/tmpxft_00005f4b_00000000-6_roi_align_kernel.cpp1.ii".
ninja: build stopped: subcommand failed.`

@zhanghang1989
Copy link
Owner

Please install ninja 1.8.2 by following the instructions https://www.claudiokuenzler.com/blog/756/install-newer-ninja-build-tools-ubuntu-14.04-trusty#.WxYrvFMvzJw

@XindyTT
Copy link

XindyTT commented Jul 24, 2018

@zhanghang1989 Thank you for your reply, I tried in this way, but it doesn't work for me. The main problem for me is enclib_gpu cannot be installed, class "at::Context" has no member "getCurrentCUDAStream". Then I search for the sorece code in pytorch-master, finding that the API has been change to at::cuda::getCurrentCUDAStream, so I replace all the at::globalContext.getCurrentCUDAStream() to at::cuda::getCurrentCUDAStream and edd the header file #include "ATen/cuda/CUDAContext.h" , it is work for me.
I think maybe the master branch of pytorch has make some change with the version before?

@zhanghang1989
Copy link
Owner

Thanks a lot @XindyTT ! I will update the repo in next release.

@fanglw
Copy link

fanglw commented Oct 29, 2018

use pytorch=0.4.1 will be ok. My python version is 3.6.7.

@zhanghang1989
Copy link
Owner

This issue should have been fixed by previous PR.

@thompa2
Copy link

thompa2 commented Nov 13, 2018

I'm also getting this error: ImportError: No module named 'enclib_cpu'. I did a source install from the Pytorch master branch and installed ninja 1.8.2 as per the link above. Any suggestions?

@zhanghang1989
Copy link
Owner

Maybe it is related to this #140 (comment)

@chauhochow
Copy link

i have met the same problem. i have try it on pytorch0.4.1 and pytorch1.0, and also rename torch.h to extension.h, but i still cannot solve it. if anyone solve it?

@henanjun
Copy link

@zhanghang1989 Thank you for your reply, I tried in this way, but it doesn't work for me. The main problem for me is enclib_gpu cannot be installed, class "at::Context" has no member "getCurrentCUDAStream". Then I search for the sorece code in pytorch-master, finding that the API has been change to at::cuda::getCurrentCUDAStream, so I replace all the at::globalContext.getCurrentCUDAStream() to at::cuda::getCurrentCUDAStream and edd the header file #include "ATen/cuda/CUDAContext.h" , it is work for me.
I think maybe the master branch of pytorch has make some change with the version b

@vribeiro1 I have solved it using the PyTorch master branch, and the ['ninja', '-v'] should not be changed.

Hello. What do you mean by using Pytroch master? Do I need uninstall the current Pytorch and install a new version?

@XindyTT
Copy link

XindyTT commented Dec 31, 2018

@zhanghang1989 Thank you for your reply, I tried in this way, but it doesn't work for me. The main problem for me is enclib_gpu cannot be installed, class "at::Context" has no member "getCurrentCUDAStream". Then I search for the sorece code in pytorch-master, finding that the API has been change to at::cuda::getCurrentCUDAStream, so I replace all the at::globalContext.getCurrentCUDAStream() to at::cuda::getCurrentCUDAStream and edd the header file #include "ATen/cuda/CUDAContext.h" , it is work for me.
I think maybe the master branch of pytorch has make some change with the version b

@vribeiro1 I have solved it using the PyTorch master branch, and the ['ninja', '-v'] should not be changed.

Hello. What do you mean by using Pytroch master? Do I need uninstall the current Pytorch and install a new version?

master is the branch of Pytorch in git. However, the API and variable may change if pytorch's version update. I tried the repo in June, where the master of pytorch is version 0.5. And now the version may be higher.

@henanjun
Copy link

henanjun commented Jan 2, 2019

@zhanghang1989 Thank you for your reply, I tried in this way, but it doesn't work for me. The main problem for me is enclib_gpu cannot be installed, class "at::Context" has no member "getCurrentCUDAStream". Then I search for the sorece code in pytorch-master, finding that the API has been change to at::cuda::getCurrentCUDAStream, so I replace all the at::globalContext.getCurrentCUDAStream() to at::cuda::getCurrentCUDAStream and edd the header file #include "ATen/cuda/CUDAContext.h" , it is work for me.
I think maybe the master branch of pytorch has make some change with the version b

@vribeiro1 I have solved it using the PyTorch master branch, and the ['ninja', '-v'] should not be changed.

Hello. What do you mean by using Pytroch master? Do I need uninstall the current Pytorch and install a new version?

master is the branch of Pytorch in git. However, the API and variable may change if pytorch's version update. I tried the repo in June, where the master of pytorch is version 0.5. And now the version may be higher.

I see. Thanks for your kind reply.

@andrewwyl
Copy link

@vribeiro1 I have solved it using the PyTorch master branch, and the ['ninja', '-v'] should not be changed.

hi,Could you tell me how you solved this problem?ubuntu==16.04,python==3.5,gcc==5.4.0
cuda==9.0 torch-encoding Version is 1.0.0

@chenerg
Copy link

chenerg commented May 4, 2020

same problem with torchvision-0.5.0 pytorch-1.4.0 and ninjia 1.8.2

@zhanghang1989
Copy link
Owner

Hi, did you follow the instructions at https://hangzhang.org/PyTorch-Encoding/notes/compile.html

I suggest using the latest anaconda with CUDA 10.0 on ubuntu 16.04.

@qiaoyaya2011
Copy link

it doesn't work ,i have tried No module named 'enclib_gpu' @zhanghang1989

@qiaoyaya2011
Copy link

do you have saved this problem? @OasisYang

@qiaoyaya2011
Copy link

@zhanghang1989 I am having the same issues described above. At first I had the RuntimeError: Error building extension 'enclib_cpu' just like @OasisYang described. Then I tried replacing ['ninja', '-v'] by ['ninja', '--v'] like @liyingying05 did, and also had the ImportError: No module named 'enclib_cpu'.

I have ninja 1.8.2 installed. I pip-installed torch-encoding with no errors. Also tried installing via setup.py, which worked fine. I'm working on the Pytorch master branch. Do any of you have solved it?

i also meet this problem,have you solved it

@qiaoyaya2011
Copy link

what's the mean of PR @zhanghang1989

@qiaoyaya2011
Copy link

same problem with torchvision-0.5.0 pytorch-1.4.0 and ninjia 1.8.2

me too

@qiaoyaya2011
Copy link

Hi, did you follow the instructions at https://hangzhang.org/PyTorch-Encoding/notes/compile.html

I suggest using the latest anaconda with CUDA 10.0 on ubuntu 16.04.

it doesn't work

@zhanghang1989
Copy link
Owner

Please use pytorch 1.4.0. PyTorch 1.5 is not supported yet.

@diwamanic
Copy link

I am facing an issue like this during my installation of Pytorch_Encoding. I am trying to run this module in Windows. And I am using Anaconda for this purpose. Could someone of you please give me a detailed set of instructions as to how I properly install it and resolve the issue that I captured below:

This is the error I am getting for the installation:

INFO: pip is looking at multiple versions of to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of torch-encoding to determine which version is compatible with other requirements. This could take a while.
ERROR: Cannot install torch-encoding and torch-encoding==1.2.2b20210226 because these package versions have conflicting dependencies.

The conflict is caused by:
torch-encoding 1.2.2b20210226 depends on torch>=1.4.0
torchvision 0.5.0 depends on torch==1.4.0

To fix this you could try to:

  1. loosen the range of package versions you've specified
  2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

@zhanghang1989
Copy link
Owner

Please uninstall all the existing versions torch-encoding library in your machine. Then follow the instructions:
https://hangzhang.org/PyTorch-Encoding/notes/compile.html

@diwamanic
Copy link

Hey thanks, I have sorted out that issue. But, at the moment, I am trying to train the model with cpu. I could not do it with pip install method. Because it throws some big chunk of error: I have scoured through the whole error lines and found the place where it makes an issue.

This following is the issue:
c:\users\dmanicka\appdata\local\programs\python\python36\lib\site-packages\torch\utils\cpp_extension.py:209: UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the file specified

can you please help me get through this error?

@zhanghang1989
Copy link
Owner

I haven't used window system. Could you try using the docker option? https://hangzhang.org/PyTorch-Encoding/notes/compile.html#using-docker

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