extension-script icon indicating copy to clipboard operation
extension-script copied to clipboard

Error when build with docker, please specify the dependencies version

Open leerumor opened this issue 6 years ago • 2 comments

I tried the following: ### 1. Build on Host gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609 first I got #error You need C++14 to compile PyTorch So I set c++ 14 in CMakeLists.txt and it worked. set(CMAKE_CXX_STANDARD 14) But got error while running the script.py. With pytorch=1.3.1:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    print(torch.ops.my_ops.warp_perspective)
  File "/home/miniconda3/lib/python3.7/site-packages/torch/_ops.py", line 61, in __getattr__
    op = torch._C._jit_get_operation(qualified_op_name)
RuntimeError: No such operator my_ops::warp_perspective

with pytorch=1.2.0:

Traceback (most recent call last):
  File "test.py", line 3, in <module>
    torch.ops.load_library("/home/LiRuMei/cpp_pytorch/build/libwarp_perspective.so")
  File "/home/anaconda3/envs/torch/lib/python3.7/site-packages/torch/_ops.py", line 106, in load_library
    ctypes.CDLL(path)
  File "/home/anaconda3/envs/torch/lib/python3.7/ctypes/__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /home/cpp_pytorch/build/libwarp_perspective.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs

### 2. Build with Docker In docker the version is pytorch-nightly-cpu=1.2.0. I also had an error about

static auto registry =
  torch::jit::RegisterOperators("my_ops::warp_perspective", &warp_perspective);

I modified it as in the tutorial:

static auto registry =
  torch::RegisterOperators("my_ops::warp_perspective", &warp_perspective);

Then I successfully built the .so, but still got:

Traceback (most recent call last):
  File "script.py", line 3, in <module>
    torch.ops.load_library("example_app/build/warp_perspective/libwarp_perspective.so")
  File "/root/local/miniconda/lib/python3.7/site-packages/torch/_ops.py", line 106, in load_library
    ctypes.CDLL(path)
  File "/root/local/miniconda/lib/python3.7/ctypes/__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /libtorch/lib/libtorch_cpu.so: undefined symbol: _ZN6caffe28TypeMeta21_typeMetaDataInstanceIcEEPKNS_6detail12TypeMetaDataEv

I think the problem is about the version of pytorch & libtorch, as the Dockerfile you committed a year ago always installed the latest version. So please try again if the Docker still works or indicate the version you used, thanks a lot.

leerumor avatar Dec 07 '19 03:12 leerumor

Hit exactly the same sequence of problems, using the provided Dockerfile.

reem avatar Jan 10 '20 01:01 reem

I ran into the exact same problem as y'all. Change the wget call in the dockerfile to pull libtorch from the stable 1.4.0 release at https://download.pytorch.org/libtorch/cpu/libtorch-macos-1.4.0.zip (or manually replace the /libtorch directory with the unzipped file linked above).

Then, do something like python3 -m pip install --upgrade torch torchvision to upgrade your virtual environment's version of torch to 1.4.0.

like @leerumor suggested, the problem stems from missing symbols due to incompatible torch installation and libtorch version.

CharlieFurrer avatar Feb 19 '20 02:02 CharlieFurrer