Skip to content
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

Cannot Import numpy.core.multiarray #19

Closed
Irtza opened this issue Mar 17, 2016 · 10 comments
Closed

Cannot Import numpy.core.multiarray #19

Irtza opened this issue Mar 17, 2016 · 10 comments

Comments

@Irtza
Copy link

Irtza commented Mar 17, 2016

My Numpy version is 1.10.4 py27_1... and I have successfully build Tensorflow from source with CUDA 7.5 and tested it...

However when building Tensorflow_serving by ...
$ bazel build --local_resources 3072,0.5,1.0 tensorflow_serving/...

I get the error : (last traceback included only)

ERROR: /home/irtza/serving/tensorflow_serving/session_bundle/example/BUILD:34:1: Executing genrule //tensorflow_serving/session_bundle/example:half_plus_two failed: bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped).
RuntimeError: module compiled against API version a but this version of numpy is 9
Traceback (most recent call last):
====skipping to last =======
File "/home/irtza/.cache/bazel/_bazel_irtza/307be6be5aced7ceb1786e9bf1c7f317/serving/bazel-out/host/bin/tensorflow_serving/session_bundle/example/export_half_plus_two.runfiles/external/tf/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import

When I check numpy import from python shell I can import numpy.core.multiarray ..

following is the output of testing tensorflow_serving which also Failed.

$ bazel test tensorflow_serving/...
INFO: Waiting for response from Bazel server (pid 2482)...
ERROR: package contains errors: tensorflow/bazel-tensorflow/third_party/gpus/cuda.
ERROR: error loading package 'tensorflow/bazel-tensorflow/third_party/gpus/cuda': Extension file not found. Unable to load package for '//tensorflow:tensorflow.bzl': BUILD file not found on package path.
INFO: Elapsed time: 5.636s
ERROR: Couldn't start the build. Unable to run tests.

@kirilg Can you please help me understand the problem?
Any help by anyone would be greatly appreciated.

@Irtza
Copy link
Author

Irtza commented Mar 21, 2016

I figured it out, I was using anaconda distro..
NumPy dependency was not a problem as TF was built from source and was running fine.
$ conda update numpy seemed to work.. not sure why.. but I hope it helps.

@Irtza Irtza closed this as completed Mar 21, 2016
@kirilg
Copy link
Contributor

kirilg commented Mar 21, 2016

@Irtza Thanks! and sorry for the delay in getting back to you!
We haven't done that much testing on the GPU build in the open source release, and I wasn't sure what would make this problem GPU specific and didn't have time yet to try and reproduce the failure. Glad it worked out for you and thanks for posting the followup fix!

@Irtza
Copy link
Author

Irtza commented Mar 21, 2016

@kirilg not a GPU specific problem I think, I think it was just conda's view of numpy package not consistent with TensorFlow's.. updating numpy through conda, fixed that.

@vodp
Copy link

vodp commented May 4, 2016

I have the same problem. I am using Ubuntu 15.10 with NumPy 1.11 and has no iead why TensorFlow cannot find my numpy.

@Irtza
Copy link
Author

Irtza commented May 4, 2016

@vodp do you have an anaconda distro of python ? if yes, update conda . and then update numpy through anacoda. $conda update numpy

@vodp
Copy link

vodp commented May 4, 2016

No I am not using Anaconda. In Ubuntu I just built numpy from source.

@vodp
Copy link

vodp commented May 4, 2016

After removing the numpy compiled from source with linkage customization to openblas, re-install numpy from Ubuntu distro sudo apt-get install python-numpy and rebuild with bazel, the error above disappeared but I get a new mystical error

ERROR: /amy/serving/tensorflow_serving/session_bundle/example/BUILD:34:1: Executing genrule //tensorflow_serving/session_bundle/example:half_plus_two failed: bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 245.

@kirilg
Copy link
Contributor

kirilg commented May 5, 2016

I'm guessing the error message will include something about not finding the generated output in .runfiles/tf_serving/tensorflow_serving/... in which case the problem could be fixed in one of two ways:

  1. Upgrade Bazel to version 0.2.2+
  2. For older versions of Bazel, simply run bazel clean once and recompile with bazel build ... as usual. The problem is that older versions of Bazel don't automatically regenerate runfiles in the newly introduced workspace name and still use the old path. Cleaning (only once the first time) and recompiling should fix the problem.

@vodp
Copy link

vodp commented May 5, 2016

Actually I just install the latest Bazel

............
Build label: 0.2.2b
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Apr 25 08:08:53 2016 (1461571733)
Build timestamp: 1461571733
Build timestamp as int: 1461571733

bazel clean and rebuild do not help. The error message is very short so that I could not spot where the problem come from

INFO: From Compiling external/tf/tensorflow/contrib/tensor_forest/core/ops/update_fertile_slots_op.cc [for host]:
external/tf/tensorflow/contrib/tensor_forest/core/ops/update_fertile_slots_op.cc: In member function 'virtual void tensorflow::UpdateFertileSlots::Compute(tensorflow::OpKernelContext*)':
external/tf/tensorflow/contrib/tensor_forest/core/ops/update_fertile_slots_op.cc:187:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (; i < values->size(); ++i) {
              ^
external/tf/tensorflow/contrib/tensor_forest/core/ops/update_fertile_slots_op.cc: In member function 'void tensorflow::UpdateFertileSlots::SetNewNonFertileLeaves(tensorflow::UpdateFertileSlots::HeapValuesType*, int, tensorflow::OpKernelContext*)':
external/tf/tensorflow/contrib/tensor_forest/core/ops/update_fertile_slots_op.cc:351:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int32 i = start; i < values->size(); ++i) {
                             ^
ERROR: /amy/serving/tensorflow_serving/session_bundle/example/BUILD:34:1: Executing genrule //tensorflow_serving/session_bundle/example:half_plus_two failed: bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 245.

@RobeDM
Copy link

RobeDM commented May 11, 2017

I had a similar problem in ubuntu.
I had updated numpy using: pip install --upgrade numpy but I still had the same problem when import tensorflow:
ImportError: numpy.core.multiarray failed to import

The reason was that I had two different numpy installations (one using apt-get and one using pip). For any strange reason tensorflow was using the installation that was installled using apt-get instead of the one using pip (by default when I do import numpy, python uses the one installed with pip).

I solved it unistalling the apt-get version: apt-get remove python-numpy

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

4 participants