问题
Hi i am trying to fix this issue when i run python3 brain.py below i get this error Illegal instruction (core dumped)
from imageai.Prediction import ImagePrediction
import os
execution_path=os.getcwd()
prediction = ImagePrediction()
prediction.setModelTypeAsSqueezeNet()
prediction.setModelPath(os.path.join(execution_path, "squeezenet_weights_tf_dim_ordering_tf_kernels.h5"))
prediction.loadModel()
predictions, probabilities = prediction.predictImage(os.path.join(execution_path, "giraffe.jpg"), result_count=5 )
for eachPrediction, eachProbability in zip(predictions, probabilities):
print(eachPrediction , " : " , eachProbability)
I have tried to downgrade Tensorflow to 1.5.0 but then after i run that i get these errors
[ons mar 25 23:11:45] Jonathan@Whats next?:~/ReallySmartBrain$ pip3 install tensorflow==1.5.0
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement tensorflow==1.5.0 (from versions: 1.13.0rc1, 1.13.0rc2, 1.13.1, 1.13.2, 1.14.0rc0, 1.14.0rc1, 1.14.0, 1.15.0rc0, 1.15.0rc1, 1.15.0rc2, 1.15.0rc3, 1.15.0, 1.15.2, 2.0.0a0, 2.0.0b0, 2.0.0b1, 2.0.0rc0, 2.0.0rc1, 2.0.0rc2, 2.0.0, 2.0.1, 2.1.0rc0, 2.1.0rc1, 2.1.0rc2, 2.1.0, 2.2.0rc0, 2.2.0rc1)
ERROR: No matching distribution found for tensorflow==1.5.0
The other solution is to compile it from source code but i'don't have any idea to compile it from source code. Can i fix this anyway?
回答1:
I had the same problem. It seems that this problem is for older CPUs. As you said, one solution is with a downgrade to tensorflow 1.5.0.
The other solution (that one that worked for me) is to build tensorflow from source.
I compiled the version 2.1.0, it took me around 25 hours with a Intel(R) Pentium(R) Dual CPU T2370 @ 1.73GHz and 2GB RAM.
You would need to install the proper version of Bazel. Find below the complete instructions from tensorflow:
https://www.tensorflow.org/install/source
I needed to add a swap file of 4GB. Otherwise you will go out of memory during the compilation.
Anyway, I have uploaded my .whl file in case you don't want to expend 25 hours (or more) to compile your own file:
https://drive.google.com/open?id=1ISgMcDiCw5W5MFvS5Zbme6pNBbA7xWMH
来源:https://stackoverflow.com/questions/60858317/how-to-fix-illegal-instruction-core-dumped