<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Undefned symbol linking own shared lib with intel mkl libs in tensorflow custom op in Intel® Distribution for Python*</title>
    <link>https://community.intel.com/t5/Intel-Distribution-for-Python/Undefned-symbol-linking-own-shared-lib-with-intel-mkl-libs-in/m-p/1145915#M1032</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I am wanting to implement the extended eigensolver routine -&amp;nbsp; &lt;EM&gt;mkl_sparse_?_ev &lt;/EM&gt;- in a custom op for tensorflow. I have run the examples for this routine, so the libraries are installed correctly, also, the compiling and linking stages dont spit out any errors. However during run time where I call the custom method from python, &lt;EM&gt;mkl_sparse_?_ev&lt;/EM&gt; is undefined as well as &lt;EM&gt;mkl_sparse_init&amp;nbsp; &lt;/EM&gt;and &lt;EM&gt;mkl_sparse_ee.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;My LD_LIBRARYPATH contains the path to the mkl lib, so I am completely stumped.&lt;/P&gt;&lt;P&gt;I have tried to create a small example which is attached, the problem is that it requires that the user has tensorflow installed from source.&lt;/P&gt;&lt;P&gt;For those who want to take a quick glance, this is my command line procedure.&lt;/P&gt;&lt;P&gt;1) The terminal sources compilervars.sh on start up&lt;/P&gt;&lt;P&gt;2) I set the tensorflow cflags and lflags&lt;/P&gt;&lt;P&gt;TF_CFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') )&lt;BR /&gt;TF_LFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') )&lt;/P&gt;&lt;P&gt;3) Compile and link the shared lib as per link line advisor&lt;/P&gt;&lt;P&gt;g++ -std=c++17 -shared -o tf_custom_ops.so -fPIC -DMKL_ILP64 -m64 -I${MKLROOT}/include -L${MKLROOT}/lib/intel64l_in -Wl,--no-as-needed -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -ltensorflow_framework -I/home/pas/software/tensorflow -O3 ml_ops.cc&lt;/P&gt;&lt;P&gt;Using ldd shows that all libraries are found.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for those who can take the time to help with this issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OS: Linux - Ubuntu 16.04 LTS&lt;/P&gt;&lt;P&gt;GCC version: 5.4&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Pascoe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Feb 2019 14:28:17 GMT</pubDate>
    <dc:creator>Scholle__Pascoe</dc:creator>
    <dc:date>2019-02-04T14:28:17Z</dc:date>
    <item>
      <title>Undefned symbol linking own shared lib with intel mkl libs in tensorflow custom op</title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/Undefned-symbol-linking-own-shared-lib-with-intel-mkl-libs-in/m-p/1145915#M1032</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I am wanting to implement the extended eigensolver routine -&amp;nbsp; &lt;EM&gt;mkl_sparse_?_ev &lt;/EM&gt;- in a custom op for tensorflow. I have run the examples for this routine, so the libraries are installed correctly, also, the compiling and linking stages dont spit out any errors. However during run time where I call the custom method from python, &lt;EM&gt;mkl_sparse_?_ev&lt;/EM&gt; is undefined as well as &lt;EM&gt;mkl_sparse_init&amp;nbsp; &lt;/EM&gt;and &lt;EM&gt;mkl_sparse_ee.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;My LD_LIBRARYPATH contains the path to the mkl lib, so I am completely stumped.&lt;/P&gt;&lt;P&gt;I have tried to create a small example which is attached, the problem is that it requires that the user has tensorflow installed from source.&lt;/P&gt;&lt;P&gt;For those who want to take a quick glance, this is my command line procedure.&lt;/P&gt;&lt;P&gt;1) The terminal sources compilervars.sh on start up&lt;/P&gt;&lt;P&gt;2) I set the tensorflow cflags and lflags&lt;/P&gt;&lt;P&gt;TF_CFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') )&lt;BR /&gt;TF_LFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') )&lt;/P&gt;&lt;P&gt;3) Compile and link the shared lib as per link line advisor&lt;/P&gt;&lt;P&gt;g++ -std=c++17 -shared -o tf_custom_ops.so -fPIC -DMKL_ILP64 -m64 -I${MKLROOT}/include -L${MKLROOT}/lib/intel64l_in -Wl,--no-as-needed -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -ltensorflow_framework -I/home/pas/software/tensorflow -O3 ml_ops.cc&lt;/P&gt;&lt;P&gt;Using ldd shows that all libraries are found.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for those who can take the time to help with this issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OS: Linux - Ubuntu 16.04 LTS&lt;/P&gt;&lt;P&gt;GCC version: 5.4&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Pascoe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 14:28:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/Undefned-symbol-linking-own-shared-lib-with-intel-mkl-libs-in/m-p/1145915#M1032</guid>
      <dc:creator>Scholle__Pascoe</dc:creator>
      <dc:date>2019-02-04T14:28:17Z</dc:date>
    </item>
  </channel>
</rss>

