Cannot Import numpy.core.multiarray
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.
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 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!
@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.
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.
@vodp do you have an anaconda distro of python ? if yes, update conda . and then update numpy through anacoda. $conda update numpy
No I am not using Anaconda. In Ubuntu I just built numpy from source.
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.
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:
- Upgrade Bazel to version 0.2.2+
- For older versions of Bazel, simply run
bazel cleanonce and recompile withbazel 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.
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.
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