ngraph icon indicating copy to clipboard operation
ngraph copied to clipboard

Documentation issues in how to import model section

Open philtomson opened this issue 8 years ago • 8 comments

I followed the instructions on the import page ( http://ngraph.nervanasys.com/docs/latest/howto/import.html ). When I got to number 4: "Confirm ngraph is properly installed through a Python interpreter:":

$ python3
Python 3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ngraph as ng
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/libraries/ngraph/python/dist/onnx/lib/python3.6/site-packages/ngraph/__init__.py", line 18, in <module>
    from ngraph.ops import absolute
  File "/opt/libraries/ngraph/python/dist/onnx/lib/python3.6/site-packages/ngraph/ops.py", line 20, in <module>
    from ngraph.impl import AxisSet, AxisVector, Coordinate, CoordinateDiff, Function, Node, \
  File "/opt/libraries/ngraph/python/dist/onnx/lib/python3.6/site-packages/ngraph/impl/__init__.py", line 35, in <module>
    from _pyngraph import Function
ImportError: libmkldnn.so.0: cannot open shared object file: No such file or directory

I searched around and found that libmkldnn.so.0 was under ngraph/python/dist/onnx/lib so I added that path to my LD_LIBRARY_PATH and retried the above and it works.

So it seems like a note needs to be added about setting LD_LIBRARY_PATH to add the path to the location of libmkldnn.so.0 on the "Import a model" page (http://ngraph.nervanasys.com/docs/latest/howto/import.html )

philtomson avatar May 14 '18 22:05 philtomson

Thanks for the report. If you think of anything additional you may have done beyond the instructions on the import page, please let us know. I don't think mkldnn ended up in the right place somehow.

diyessi avatar May 14 '18 22:05 diyessi

I realized that originally I had followed the instructions here for installing ngraph and then moved on to the import instructions after that. So I went to try to rebuild from scratch using the import instructions. This time after running make I ran into:

[ 23%] Building CXX object src/ngraph/CMakeFiles/ngraph.dir/function.cpp.o
/opt/libraries/ngraph/src/ngraph/function.cpp:133:15: error: ‘std::ostream& ngraph::operator<<(std::ostream&, const ngraph::Function&)’ has not been declared within ngraph [-Werror]
 std::ostream& ngraph::operator<<(std::ostream& out, const Function& f)
               ^~~~~~
In file included from /opt/libraries/ngraph/src/ngraph/function.cpp:21:0:
/opt/libraries/ngraph/src/ngraph/function.hpp:79:30: note: only here as a friend
         friend std::ostream& operator<<(std::ostream&, const Function&);
                              ^~~~~~~~
cc1plus: all warnings being treated as errors
src/ngraph/CMakeFiles/ngraph.dir/build.make:374: recipe for target 'src/ngraph/CMakeFiles/ngraph.dir/function.cpp.o' failed
make[2]: *** [src/ngraph/CMakeFiles/ngraph.dir/function.cpp.o] Error 1
CMakeFiles/Makefile2:379: recipe for target 'src/ngraph/CMakeFiles/ngraph.dir/all' failed

To remedy that problem I went into the CMakeLists.txt and eliminated the -Werror that was being added to the CMAKE_CXX_FLAGS there. I'm using g++ 7.3 on Ubuntu 18.04.

After that built, I still ended up with the problem of not having libmkldnn.so.0 in the LD_LIBRARY_PATH. I think I see what the problem is: If you're following the instructions for importing an ONNX file, you never really get to the bit about setting the LD_LIBRARY_PATH which is on the Activating nGraph on generic frameworks page. I went ahead and set my LD_LIBRARY_PATH as shown there (with the addition of preserving the existing LD_LIBRARY_PATH):

export LD_LIBRARY_PATH=$HOME/ngraph_dist/lib/:$LD_LIBRARY_PATH

philtomson avatar May 15 '18 01:05 philtomson

Oh, and I'll add that when I go further with the ONNX import instructions I run into a segfault:

$ python3
Python 3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import onnx
>>> onnx_protobuf = onnx.load('/home/phil/devel/ML/Julia/NeuralNet/onnx_tests/squeezenet/model.onnx')
>>> from ngraph_onnx.onnx_importer.importer import import_onnx_model
Segmentation fault (core dumped)

This is on Ubuntu 18.04 so maybe some library is too new on my system.

philtomson avatar May 15 '18 01:05 philtomson

Hi @philtomson, thanks for the investigation!

Our officially supported OS's/Compilers are Centos 7 and Ubuntu 16.04, with gcc 4.8, gcc 5.4, and clang 3.9. We've just started testing with Ubuntu 18.04 internally, it looks like there's a compatibility mismatch somewhere with the update to gcc 7.3. We'll keep you in the loop as we try to find the root cause.

mbrookhart avatar May 15 '18 01:05 mbrookhart

The Segmentation fault (core dumped) error is most likely related to a bug in ONNX version 1.1.2: https://github.com/onnx/onnx/issues/875

Please try to install ONNX v. 1.1.1

# apt install protobuf-compiler libprotobuf-dev
(venv)$ pip install onnx==1.1.1

postrational avatar May 15 '18 13:05 postrational

@postrational: yes, installing ONNX 1.1.1 got rid of the segfault.

philtomson avatar May 15 '18 23:05 philtomson

I believe the other issues are also addressed in master now.

diyessi avatar May 16 '18 00:05 diyessi

PRs that address these issues have been merged, so I am closing this; the documentation issues were addressed and tested.

indie avatar May 21 '18 15:05 indie