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

F tensorflow/python/lib/core/bfloat16.cc:664] Check failed: PyBfloat16_Type.tp_base != nullptr Aborted #68

Closed
monajalal opened this issue Apr 8, 2018 · 8 comments

Comments

@monajalal
Copy link

So when running the test.py code, I get this error:

    [jalal@goku pose-tensorflow]$ TF_CUDNN_USE_AUTOTUNE=0 python demo/demo_multiperson.py
    RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
    ImportError: numpy.core.multiarray failed to import
    ImportError: numpy.core.umath failed to import
    ImportError: numpy.core.umath failed to import
    2018-04-08 17:09:02.321666: F tensorflow/python/lib/core/bfloat16.cc:664] Check failed: PyBfloat16_Type.tp_base != nullptr 
    Aborted

The test.py code is:

  import argparse
   import logging
   import os

   import numpy as np
   import scipy.io
   import scipy.ndimage
   
   from config import load_config
   from dataset.factory import create as create_dataset
   from dataset.pose_dataset import Batch
   from nnet.predict import setup_pose_prediction, extract_cnn_output, argmax_pose_predict
   from util import visualize
   
   
   def test_net(visualise, cache_scoremaps):
       logging.basicConfig(level=logging.INFO)
   
       cfg = load_config()
       dataset = create_dataset(cfg)
       dataset.set_shuffle(False)
       dataset.set_test_mode(True)
   
       sess, inputs, outputs = setup_pose_prediction(cfg)
   
       if cache_scoremaps:
           out_dir = cfg.scoremap_dir
           if not os.path.exists(out_dir):
               os.makedirs(out_dir)
   
       num_images = dataset.num_images
       predictions = np.zeros((num_images,), dtype=np.object)
   
       for k in range(num_images):
           print('processing image {}/{}'.format(k, num_images-1))
   
           batch = dataset.next_batch()
   
           outputs_np = sess.run(outputs, feed_dict={inputs: batch[Batch.inputs]})
   
           scmap, locref, pairwise_diff = extract_cnn_output(outputs_np, cfg)
   
           pose = argmax_pose_predict(scmap, locref, cfg.stride)
   
           pose_refscale = np.copy(pose)
           pose_refscale[:, 0:2] /= cfg.global_scale
           predictions[k] = pose_refscale
   
           if visualise:
               img = np.squeeze(batch[Batch.inputs]).astype('uint8')
               visualize.show_heatmaps(cfg, img, scmap, pose)
               visualize.waitforbuttonpress()
   
           if cache_scoremaps:
               base = os.path.basename(batch[Batch.data_item].im_path)
               raw_name = os.path.splitext(base)[0]
               out_fn = os.path.join(out_dir, raw_name + '.mat')
               scipy.io.savemat(out_fn, mdict={'scoremaps': scmap.astype('float32')})
   
               out_fn = os.path.join(out_dir, raw_name + '_locreg' + '.mat')
               if cfg.location_refinement:
                   scipy.io.savemat(out_fn, mdict={'locreg_pred': locref.astype('float32')})
   
       scipy.io.savemat('predictions.mat', mdict={'joints': predictions})
   
       sess.close()
   
   
   if __name__ == '__main__':
       parser = argparse.ArgumentParser()
       parser.add_argument('--novis', default=False, action='store_true')
       parser.add_argument('--cache', default=False, action='store_true')
       args, unparsed = parser.parse_known_args()
   
       test_net(not args.novis, args.cache)

I have the followings:

  $ conda list tensorflow
   # packages in environment at /scratch/sjn/anaconda:
   #
   tensorflow                1.5.0                    py36_0    conda-forge
   tensorflow-gpu            1.3.0                         0  
   tensorflow-gpu-base       1.3.0           py36cuda8.0cudnn6.0_1  
   tensorflow-tensorboard    0.1.5                    py36_0  

and

$ conda list numpy
  # packages in environment at /scratch/sjn/anaconda:
  #
  msgpack-numpy             0.4.1                     <pip>
  numpy                     1.13.3          py36_blas_openblas_201  [blas_openblas]  conda-forge
  numpydoc                  0.7.0            py36h18f165f_0  

@monajalal
Copy link
Author

Installed tensorflow 1.4.0 and the issue was resolved!

@Huixxi
Copy link

Huixxi commented Oct 15, 2018

conda install tensorflow
I solved this issue with it.

@elan69
Copy link

elan69 commented Oct 21, 2018

still dosnt work @Huixxi

@lidejian
Copy link

lidejian commented Jan 11, 2019

@elanChezhianMuthuvel it needs numpy>=1.14,so pip install numpy==1.14 and it work!

@foxjr
Copy link

foxjr commented Jan 23, 2019

I'm using a custom TF 1.10.0 configuration that doesn't use AVX instructions. I got this error when using the numpy version that accompanied my custom configuration (1.14.1); however, upgrading to latest (1.16.x) resolved the issue, despite a prompt that it could be incompatible.

@weltonmattos
Copy link

I'm using a custom TF 1.10.0 configuration that doesn't use AVX instructions. I got this error when using the numpy version that accompanied my custom configuration (1.14.1); however, upgrading to latest (1.16.x) resolved the issue, despite a prompt that it could be incompatible.

i solved by uninstalling current version from numpy and by reinstalling with the last version.
pip uninstall numpy and pip install numpy

@dinakarmaurya-innova
Copy link

above problem was same with me - nice answer by weltonmattos

pip uninstall numpy and pip install numpy
above will fix issue.
Thank you.

@wzelang
Copy link

wzelang commented Aug 21, 2019

tensorflow 1.13 needs numpy >=1.16, update numpy from 1.14 to 1.16 works for me.

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

8 participants