Skip to content

Python package testing/installation failing, due to missing *.h file in non-existent directory! #3262

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

Closed
capn-freako opened this issue Jul 19, 2019 · 8 comments

Comments

@capn-freako
Copy link

Attempting to follow the instructions in docs/pytorch.md, Python package testing and installation are failing:

(pytorch)
dbanas@Davids-MacBook-Pro:~/Documents/Projects/PyTorch-Glow/glow/torch_glow
$ python setup.py test --cmake_prefix_path=/usr/local/Cellar/llvm\@7/7.0.1/lib/cmake/llvm/
{snip}
[ 94%] Building CXX object tools/loader/CMakeFiles/text-translator.dir/TextTranslator.cpp.o
/Users/dbanas/Documents/Projects/PyTorch-Glow/glow/torch_glow/src/binding.cpp:20:10: fatal error: 'torch/csrc/jit/operator_options.h' file not found
#include <torch/csrc/jit/operator_options.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/dbanas/Documents/Projects/PyTorch-Glow/glow/torch_glow/src/PyTorchModelLoader.cpp:533:35: error: no member named 'toVector' in namespace 'c10::impl'
    const auto &vals = c10::impl::toVector(valsList);
                       ~~~~~~~~~~~^
1 error generated.
make[2]: *** [torch_glow/src/CMakeFiles/_torch_glow.dir/binding.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
{snip}

The really strange thing is: none of the intermediate directories on the path to that missing *.h file exist!

dbanas@Davids-MacBook-Pro:~/Documents/Projects/PyTorch-Glow
$ find . -type f -name 'operator_options.h'

dbanas@Davids-MacBook-Pro:~/Documents/Projects/PyTorch-Glow
$ find . -type d -name 'jit'                                                                                                                               

dbanas@Davids-MacBook-Pro:~/Documents/Projects/PyTorch-Glow
$ find . -type d -name 'csrc'

dbanas@Davids-MacBook-Pro:~/Documents/Projects/PyTorch-Glow
$ find . -type d -name 'torch'

dbanas@Davids-MacBook-Pro:~/Documents/Projects/PyTorch-Glow
@rdzhabarov
Copy link
Contributor

@jackm321 ^

@capn-freako
Copy link
Author

The results of some sleuthing:

  1. I found the torch/csrc/jit/ directory:
dbanas@Davids-MacBook-Pro:~/Documents/Projects/PyTorch-Glow
$ ls /anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/jit/
alias_info.h              interned_strings_class.h  python_ir.h
argument_spec.h           interpreter.h             python_tracer.h
attributes.h              ir.h                      resource_guard.h
autodiff.h                ir_views.h                scope.h
code_template.h           irparser.h                script/
constants.h               named_value.h             source_location.h
custom_operator.h         netdef_converter.h        source_range.h
dynamic_dag.h             node_hashing.h            subgraph_matcher.h
export.h                  operator.h                symbolic_script.h
graph_executor.h          pass_manager.h            symbolic_variable.h
graph_node_list.h         passes/                   testing/
hooks_for_testing.h       pickler.h                 tracer.h
import.h                  profiling_record.h        tracing_state.h
import_export_helpers.h   pybind.h                  variable_tensor_list.h
import_source.h           pybind_utils.h
init.h                    python_arg_flatten.h

However, there's no operator_options.h file present in that directory.

  1. On a whim, I made the following change to the binding.cpp file:
dbanas@Davids-MacBook-Pro:~/Documents/Projects/PyTorch-Glow/glow/torch_glow
$ git diff
diff --git a/torch_glow/src/binding.cpp b/torch_glow/src/binding.cpp
index f2254a42..7961df83 100644
--- a/torch_glow/src/binding.cpp
+++ b/torch_glow/src/binding.cpp
@@ -17,7 +17,7 @@
 #include <pybind11/pybind11.h>

 #include <torch/csrc/jit/custom_operator.h>
-#include <torch/csrc/jit/operator_options.h>
+#include <torch/csrc/jit/operator.h>
 #include <torch/csrc/jit/pass_manager.h>
 #include <torch/csrc/jit/passes/graph_fuser.h>

And then attempted: python setup.py install, again, which generated these errors:

[ 98%] Built target GlowOnnxifiManagerTest
/Users/dbanas/Documents/Projects/PyTorch-Glow/glow/torch_glow/src/PyTorchModelLoader.cpp:533:35: error: no member named 'toVector' in namespace 'c10::impl'
    const auto &vals = c10::impl::toVector(valsList);
                       ~~~~~~~~~~~^
/Users/dbanas/Documents/Projects/PyTorch-Glow/glow/torch_glow/src/binding.cpp:53:23: error: no member named 'OperatorOptions' in namespace 'c10'
  auto options = c10::OperatorOptions();
                 ~~~~~^
/Users/dbanas/Documents/Projects/PyTorch-Glow/glow/torch_glow/src/binding.cpp:54:32: error: no member named 'AliasAnalysisKind' in namespace 'at'
  options.setAliasAnalysis(at::AliasAnalysisKind::PURE);
                           ~~~~^
/Users/dbanas/Documents/Projects/PyTorch-Glow/glow/torch_glow/src/binding.cpp:72:19: error: no member named 'CustomFuseGraph' in namespace 'torch::jit'
      torch::jit::CustomFuseGraph(g, PyTorchModelLoader::isNodeSupported,
      ~~~~~~~~~~~~^
1 error generated.
make[2]: *** [torch_glow/src/CMakeFiles/_torch_glow.dir/PyTorchModelLoader.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
3 errors generated.
make[2]: *** [torch_glow/src/CMakeFiles/_torch_glow.dir/binding.cpp.o] Error 1
make[1]: *** [torch_glow/src/CMakeFiles/_torch_glow.dir/all] Error 2
make: *** [all] Error 2
Traceback (most recent call last):
  File "setup.py", line 215, in <module>
    url='https://github.com/pytorch/glow',
  File "/anaconda3/envs/pytorch/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/anaconda3/envs/pytorch/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/anaconda3/envs/pytorch/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/anaconda3/envs/pytorch/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/anaconda3/envs/pytorch/lib/python3.7/site-packages/setuptools/command/install.py", line 67, in run
    self.do_egg_install()
  File "/anaconda3/envs/pytorch/lib/python3.7/site-packages/setuptools/command/install.py", line 109, in do_egg_install
    self.run_command('bdist_egg')
  File "/anaconda3/envs/pytorch/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/anaconda3/envs/pytorch/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/anaconda3/envs/pytorch/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 172, in run
    cmd = self.call_command('install_lib', warn_dir=0)
  File "/anaconda3/envs/pytorch/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 158, in call_command
    self.run_command(cmdname)
  File "/anaconda3/envs/pytorch/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/anaconda3/envs/pytorch/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/anaconda3/envs/pytorch/lib/python3.7/site-packages/setuptools/command/install_lib.py", line 11, in run
    self.build()
  File "/anaconda3/envs/pytorch/lib/python3.7/distutils/command/install_lib.py", line 107, in build
    self.run_command('build_ext')
  File "/anaconda3/envs/pytorch/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/anaconda3/envs/pytorch/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "setup.py", line 152, in run
    self.run_command('cmake_build')
  File "/anaconda3/envs/pytorch/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/anaconda3/envs/pytorch/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "setup.py", line 141, in run
    self._run_build()
  File "setup.py", line 133, in _run_build
    subprocess.check_call(build_args)
  File "/anaconda3/envs/pytorch/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/local/bin/cmake', '--build', '.', '--', '-j', '12']' returned non-zero exit status 2.

@jackm321
Copy link
Contributor

These look like things that are currently available only in pytorch nightly build but not in regular build so I'm pretty sure the issue is that it's not using the nightly version.
I realized recently that installing torchvision also installs regular build of pytorch so that could cause this to happen. I need to remove that from docs/pytorch.md. If you unsinstall the torch packages from you environment and then only install nightly pytorch build and not torchvision does it fix the issue?

@jackm321
Copy link
Contributor

Hm actually I removed the torchvision instructions already so that may not be the cause of the wrong torch version but I think that still may be the issue. If you run python -c "import torch; print(torch.__version__)" where you were running the setup script, what do you get? It should be something with dev in it.

@capn-freako
Copy link
Author

@jackm321 , thanks for your reply!

(pytorch)
dbanas@Davids-MacBook-Pro:~/Documents/Projects/PyTorch-Glow/glow/torch_glow
$ python -c 'import torch; print(torch.__version__)'
1.1.0

@capn-freako
Copy link
Author

Trying to follow your second comment...

At this site, I'd originally selected Stable (1.1).
And it prescribed this command: conda install pytorch torchvision -c pytorch, which I ran.
I notice that, if I instead select Preview (Nightly), then it prescribes this command: conda install pytorch-nightly -c pytorch.
Are you suggesting that I:

  1. run the command: conda uninstall pytorch,
  2. run the command: conda uninstall torchvision,
  3. run the command: conda install torchvision, and
  4. run the command: conda install pytorch-nightly -c pytorch?

@capn-freako
Copy link
Author

Okay, I tried the 4 steps I proposed, above, with the following results:

  1. Succeeded.
  2. Failed, but only because step Remove a failing LRN test. #1 removed the torchvision package.
  3. Failed, complaining that the torchvision package couldn't be found in any of the channels: main, free, r, or conda-forge.
  4. Succeeded.

Then, running python setup.py test from within the glow/torch_glow/ subdirectory succeeds:

==================================================================== test session starts ====================================================================
platform darwin -- Python 3.7.3, pytest-5.0.1, py-1.8.0, pluggy-0.12.0 -- /anaconda3/envs/pytorch/bin/python
cachedir: .pytest_cache
rootdir: /Users/dbanas/Documents/Projects/PyTorch-Glow/glow/torch_glow, inifile: setup.cfg, testpaths: tests
collected 17 items

tests/nodes/adaptive_avg_pool2d_test.py::test_adaptive_avg_pool2d_basic PASSED                                                                        [  5%]
tests/nodes/adaptive_avg_pool2d_test.py::test_adaptive_avg_pool2d_nonsquare_inputs PASSED                                                             [ 11%]
tests/nodes/adaptive_avg_pool2d_test.py::test_adaptive_avg_pool2d_nonsquare_outputs PASSED                                                            [ 17%]
tests/nodes/add_test.py::test_add_basic PASSED                                                                                                        [ 23%]
tests/nodes/add_test.py::test_add_inplace PASSED                                                                                                      [ 29%]
tests/nodes/batchnorm_test.py::test_batchnorm_basic PASSED                                                                                            [ 35%]
tests/nodes/batchnorm_test.py::test_batchnorm_with_weights PASSED                                                                                     [ 41%]
tests/nodes/conv2d_test.py::test_conv2d_basic PASSED                                                                                                  [ 47%]
tests/nodes/conv2d_test.py::test_conv2d_with_bias PASSED                                                                                              [ 52%]
tests/nodes/conv2d_test.py::test_conv2d_param_sweep SKIPPED                                                                                           [ 58%]
tests/nodes/div_test.py::test_div_basic PASSED                                                                                                        [ 64%]
tests/nodes/maxpool2d_test.py::test_max_pool2d_basic PASSED                                                                                           [ 70%]
tests/nodes/maxpool2d_test.py::test_max_pool2d_with_args PASSED                                                                                       [ 76%]
tests/nodes/mul_test.py::test_mul_basic PASSED                                                                                                        [ 82%]
tests/nodes/relu_test.py::test_relu_basic PASSED                                                                                                      [ 88%]
tests/nodes/relu_test.py::test_relu_inplace PASSED                                                                                                    [ 94%]
tests/nodes/sub_test.py::test_sub_basic PASSED                                                                                                        [100%]

=========================================================== 16 passed, 1 skipped in 0.57 seconds ============================================================

(I assume the one skipped test is expected; is that true?)

And:

(pytorch)
dbanas@Davids-MacBook-Pro:~/Documents/Projects/PyTorch-Glow/glow/torch_glow
$ python -c 'import torch; print(torch.__version__)'
1.2.0.dev20190719

which I presume is correct, since you said the version number should have a "dev" in it.

And, finally, referring to the instructions at the very end of the docs/pytorch.md file:

(pytorch)
dbanas@Davids-MacBook-Pro:~/Documents/Projects/PyTorch-Glow/glow/torch_glow
$ python -c 'import torch_glow'
(pytorch)
dbanas@Davids-MacBook-Pro:~/Documents/Projects/PyTorch-Glow/glow/torch_glow
$

which I presume indicates success, since no error was reported.

@jackm321
Copy link
Contributor

Awesome! Yep looks like that did the trick. The 1 skipped test expected.
Going to close this now, feel free to reopen if something isn't working.

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

3 participants