zhanghang1989 / PyTorch-Encoding

A CV toolkit for my papers.
https://hangzhang.org/PyTorch-Encoding/
MIT License
2.04k stars 450 forks source link

ImportError: No module named enclib_cpu #158

Closed Rachel07 closed 4 years ago

Rachel07 commented 5 years ago

Traceback (most recent call last): File "test.py", line 16, in import encoding.utils as utils File "/usr/local/lib/python2.7/dist-packages/encoding/init.py", line 13, in from . import nn, functions, parallel, utils, models, datasets, transforms File "/usr/local/lib/python2.7/dist-packages/encoding/nn/init.py", line 12, in from .encoding import File "/usr/local/lib/python2.7/dist-packages/encoding/nn/encoding.py", line 18, in from ..functions import scaled_l2, aggregate, pairwise_cosine File "/usr/local/lib/python2.7/dist-packages/encoding/functions/init.py", line 2, in from .encoding import File "/usr/local/lib/python2.7/dist-packages/encoding/functions/encoding.py", line 14, in from .. import lib File "/usr/local/lib/python2.7/dist-packages/encoding/lib/init.py", line 15, in ], build_directory=cpu_path, verbose=False) File "/usr/local/lib/python2.7/dist-packages/torch/utils/cpp_extension.py", line 645, in load is_python_module) File "/usr/local/lib/python2.7/dist-packages/torch/utils/cpp_extension.py", line 825, in _jit_compile return _import_module_from_library(name, build_directory, is_python_module) File "/usr/local/lib/python2.7/dist-packages/torch/utils/cpp_extension.py", line 964, in _import_module_from_library file, path, description = imp.find_module(module_name, [path]) ImportError: No module named enclib_cpu My pytorch version is 1.0stable ,cuda version 9.0, python 2.7 Although i have used the latest copy of the code(Pytorch-Encoding), i still encounter the problem。

zhanghang1989 commented 5 years ago

The code hasn’t been tested on Python 2. Can you try python 3?

Rachel07 commented 5 years ago

Ok,I will try python3, thanks for your reply.

Rachel07 commented 5 years ago

I have tried python3(python 3.5.2), but i got a new error Traceback (most recent call last): File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 946, in _build_extension_module check=True) File "/usr/lib/python3.5/subprocess.py", line 708, 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 "test.py", line 16, in import encoding.utils as utils File "/usr/local/lib/python3.5/dist-packages/encoding/init.py", line 13, in from . import nn, functions, parallel, utils, models, datasets, transforms File "/usr/local/lib/python3.5/dist-packages/encoding/nn/init.py", line 12, in from .encoding import File "/usr/local/lib/python3.5/dist-packages/encoding/nn/encoding.py", line 18, in from ..functions import scaled_l2, aggregate, pairwise_cosine File "/usr/local/lib/python3.5/dist-packages/encoding/functions/init.py", line 2, in from .encoding import File "/usr/local/lib/python3.5/dist-packages/encoding/functions/encoding.py", line 14, in from .. import lib File "/usr/local/lib/python3.5/dist-packages/encoding/lib/init.py", line 27, in build_directory=gpu_path, verbose=False) File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 645, in load is_python_module) File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 814, in _jit_compile with_cuda=with_cuda) File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 863, in _write_ninja_file_and_build _build_extension_module(name, build_directory, verbose) File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 959, in _build_extension_module raise RuntimeError(message) RuntimeError: Error building extension 'enclib_gpu': [1/8] c++ -MMD -MF operator.o.d -DTORCH_EXTENSION_NAME=enclib_gpu -DTORCH_API_INCLUDE_EXTENSION_H -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/torch/csrc/api/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/TH -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.5m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++11 -c /usr/local/lib/python3.5/dist-packages/encoding/lib/gpu/operator.cpp -o operator.o [2/8] /usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=enclib_gpu -DTORCH_API_INCLUDE_EXTENSION_H -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/torch/csrc/api/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/TH -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.5m -D_GLIBCXX_USE_CXX11_ABI=0 -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS --compiler-options '-fPIC' --expt-extended-lambda -std=c++11 -c /usr/local/lib/python3.5/dist-packages/encoding/lib/gpu/encodingv2_kernel.cu -o encodingv2_kernel.cuda.o FAILED: encodingv2_kernel.cuda.o /usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=enclib_gpu -DTORCH_API_INCLUDE_EXTENSION_H -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/torch/csrc/api/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/TH -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.5m -D_GLIBCXX_USE_CXX11_ABI=0 -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS --compiler-options '-fPIC' --expt-extended-lambda -std=c++11 -c /usr/local/lib/python3.5/dist-packages/encoding/lib/gpu/encodingv2_kernel.cu -o encodingv2_kernel.cuda.o

zhanghang1989 commented 5 years ago

Sorry about the running error. I am not good at system debugging. Could you try my setting ---- anaconda 3.6 with PyTorch Stable 1.0?

henanjun commented 5 years ago

Sorry about the running error. I am not good at system debugging. Could you try my setting ---- anaconda 3.6 with PyTorch Stable 1.0?

Hi, Anaconda 3.6 means Anconda with python 3.6 ?

zhanghang1989 commented 5 years ago

Hi, Anaconda 3.6 means Anconda with python 3.6 ?

Yeah. Please use CUDA 9.2 as well.

huanghoujing commented 5 years ago

I use python 2.7, pytorch 1.0 and Pytorch-Encoding v1.0.0/v1.0.1. If you still have problem with installation, this may help. I find it necessary to

My installation guide is this and then this.

johkpunch321 commented 5 years ago

i use anaconda env to execute the project. For material recognition, i can only train my owe model by using default dataset( cifar 10), once i switch the dataset by digit command --dataset minc, it will give me the errors.

johkpunch321 commented 5 years ago

Traceback (most recent call last): File "main.py", line 181, in main() File "main.py", line 50, in main model = encoding.models.get_model(args.model, pretrained=args.pretrained) File "/home/SOCNET/the1/anaconda3/lib/python3.7/site-packages/encoding/models/model_zoo.py", line 48, in get_model raise ValueError('%s\n\t%s' % (str(name), '\n\t'.join(sorted(models.keys())))) ValueError: densenet cifar_resnet20 deepten_resnet50_minc encnet_resnet101_ade encnet_resnet101_pcontext encnet_resnet50_ade encnet_resnet50_pcontext fcn_resnet50_ade fcn_resnet50_pcontext psp_resnet50_ade resnet101 resnet152 resnet18 resnet34 resnet50 170500096it [01:50, 1545983.83it/s]

zhanghang1989 commented 5 years ago

can you try --model deepten_resnet50_minc

johkpunch321 commented 5 years ago

Still cannot work. Also i got other issues when tested your code. Can we talk by Wechat or something?

zhanghang1989 commented 5 years ago

Could you send an email to zhanghang0704@gmail.com

qiaoyaya2011 commented 4 years ago

import encoding Traceback (most recent call last): File "", line 1, in File "/home/qiao/anaconda3/envs/encoding/lib/python3.7/site-packages/encoding/init.py", line 13, in from . import nn, functions, parallel, utils, models, datasets, transforms File "/home/qiao/anaconda3/envs/encoding/lib/python3.7/site-packages/encoding/nn/init.py", line 12, in from .encoding import File "/home/qiao/anaconda3/envs/encoding/lib/python3.7/site-packages/encoding/nn/encoding.py", line 18, in from ..functions import scaled_l2, aggregate, pairwise_cosine File "/home/qiao/anaconda3/envs/encoding/lib/python3.7/site-packages/encoding/functions/init.py", line 2, in from .encoding import File "/home/qiao/anaconda3/envs/encoding/lib/python3.7/site-packages/encoding/functions/encoding.py", line 14, in from .. import lib File "/home/qiao/anaconda3/envs/encoding/lib/python3.7/site-packages/encoding/lib/init.py", line 29, in build_directory=gpu_path, verbose=False) File "/home/qiao/anaconda3/envs/encoding/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 680, in load is_python_module) File "/home/qiao/anaconda3/envs/encoding/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 877, in _jit_compile return _import_module_from_library(name, build_directory, is_python_module) File "/home/qiao/anaconda3/envs/encoding/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1084, in _import_module_from_library file, path, description = imp.find_module(module_name, [path]) File "/home/qiao/anaconda3/envs/encoding/lib/python3.7/imp.py", line 296, in find_module raise ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named 'enclib_gpu'

i try the detailed steps here https://hangzhang.org/PyTorch-Encoding/notes/compile.html#detailed-steps, but always error. my god. anaconda Anaconda3-2020.02-Linux-x86_64.sh ubuntu 16.04, CUDA 10.0 cudnn 7.5 torch 1.4.0 torchvision 0.5.0 torch-encoding 1.2.2b20200705 python 3.7.6 I don't know what to do @zhanghang1989

wanghao9610 commented 4 years ago

I have tried python3(python 3.5.2), but i got a new error Traceback (most recent call last): File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 946, in _build_extension_module check=True) File "/usr/lib/python3.5/subprocess.py", line 708, 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 "test.py", line 16, in import encoding.utils as utils File "/usr/local/lib/python3.5/dist-packages/encoding/init.py", line 13, in from . import nn, functions, parallel, utils, models, datasets, transforms File "/usr/local/lib/python3.5/dist-packages/encoding/nn/init.py", line 12, in from .encoding import File "/usr/local/lib/python3.5/dist-packages/encoding/nn/encoding.py", line 18, in from ..functions import scaled_l2, aggregate, pairwise_cosine File "/usr/local/lib/python3.5/dist-packages/encoding/functions/init.py", line 2, in from .encoding import File "/usr/local/lib/python3.5/dist-packages/encoding/functions/encoding.py", line 14, in from .. import lib File "/usr/local/lib/python3.5/dist-packages/encoding/lib/init.py", line 27, in build_directory=gpu_path, verbose=False) File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 645, in load is_python_module) File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 814, in _jit_compile with_cuda=with_cuda) File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 863, in _write_ninja_file_and_build _build_extension_module(name, build_directory, verbose) File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 959, in _build_extension_module raise RuntimeError(message) RuntimeError: Error building extension 'enclib_gpu': [1/8] c++ -MMD -MF operator.o.d -DTORCH_EXTENSION_NAME=enclib_gpu -DTORCH_API_INCLUDE_EXTENSION_H -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/torch/csrc/api/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/TH -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.5m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++11 -c /usr/local/lib/python3.5/dist-packages/encoding/lib/gpu/operator.cpp -o operator.o [2/8] /usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=enclib_gpu -DTORCH_API_INCLUDE_EXTENSION_H -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/torch/csrc/api/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/TH -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.5m -D_GLIBCXX_USE_CXX11_ABI=0 -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS --compiler-options '-fPIC' --expt-extended-lambda -std=c++11 -c /usr/local/lib/python3.5/dist-packages/encoding/lib/gpu/encodingv2_kernel.cu -o encodingv2_kernel.cuda.o FAILED: encodingv2_kernel.cuda.o /usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=enclib_gpu -DTORCH_API_INCLUDE_EXTENSION_H -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/torch/csrc/api/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/TH -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.5m -D_GLIBCXX_USE_CXX11_ABI=0 -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS --compiler-options '-fPIC' --expt-extended-lambda -std=c++11 -c /usr/local/lib/python3.5/dist-packages/encoding/lib/gpu/encodingv2_kernel.cu -o encodingv2_kernel.cuda.o

I have tried python3(python 3.5.2), but i got a new error Traceback (most recent call last): File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 946, in _build_extension_module check=True) File "/usr/lib/python3.5/subprocess.py", line 708, 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 "test.py", line 16, in import encoding.utils as utils File "/usr/local/lib/python3.5/dist-packages/encoding/init.py", line 13, in from . import nn, functions, parallel, utils, models, datasets, transforms File "/usr/local/lib/python3.5/dist-packages/encoding/nn/init.py", line 12, in from .encoding import File "/usr/local/lib/python3.5/dist-packages/encoding/nn/encoding.py", line 18, in from ..functions import scaled_l2, aggregate, pairwise_cosine File "/usr/local/lib/python3.5/dist-packages/encoding/functions/init.py", line 2, in from .encoding import File "/usr/local/lib/python3.5/dist-packages/encoding/functions/encoding.py", line 14, in from .. import lib File "/usr/local/lib/python3.5/dist-packages/encoding/lib/init.py", line 27, in build_directory=gpu_path, verbose=False) File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 645, in load is_python_module) File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 814, in _jit_compile with_cuda=with_cuda) File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 863, in _write_ninja_file_and_build _build_extension_module(name, build_directory, verbose) File "/home/radmin/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 959, in _build_extension_module raise RuntimeError(message) RuntimeError: Error building extension 'enclib_gpu': [1/8] c++ -MMD -MF operator.o.d -DTORCH_EXTENSION_NAME=enclib_gpu -DTORCH_API_INCLUDE_EXTENSION_H -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/torch/csrc/api/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/TH -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.5m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++11 -c /usr/local/lib/python3.5/dist-packages/encoding/lib/gpu/operator.cpp -o operator.o [2/8] /usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=enclib_gpu -DTORCH_API_INCLUDE_EXTENSION_H -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/torch/csrc/api/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/TH -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.5m -D_GLIBCXX_USE_CXX11_ABI=0 -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS --compiler-options '-fPIC' --expt-extended-lambda -std=c++11 -c /usr/local/lib/python3.5/dist-packages/encoding/lib/gpu/encodingv2_kernel.cu -o encodingv2_kernel.cuda.o FAILED: encodingv2_kernel.cuda.o /usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=enclib_gpu -DTORCH_API_INCLUDE_EXTENSION_H -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/torch/csrc/api/include -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/TH -isystem /home/radmin/.local/lib/python3.5/site-packages/torch/lib/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.5m -D_GLIBCXX_USE_CXX11_ABI=0 -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS --compiler-options '-fPIC' --expt-extended-lambda -std=c++11 -c /usr/local/lib/python3.5/dist-packages/encoding/lib/gpu/encodingv2_kernel.cu -o encodingv2_kernel.cuda.o

I have met the same error, this error may be caused by ninja version or your cuda or gcc version are not compatible, and you may need to add gcc, cuda lib path to your ~/.bashrc. Try: ninja 1.8.2, cuda 10.0, gcc 5.5.0, pytorch 1.4.0. It worked.