Solution process:
提示:这里简述项目相关背景:
When keras-yolov3 is used with the virtual environment Python3.7 (tensorflow-gpu)
to run predict.py, an error occurs and the prompt is as follows:
-
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory
indicates that cuda is not compatible with the tensorflow version. Improve tensorflow to version 2.0 or above (my version at the time was keras=2.6.0; tensorflow=2.6.0 ) - After running, the error message is as follows:
ModuleNotFoundError: No module named
‘keras.layers.advanced_activations’
Refer to this netizen’s solution: 12345
First downgrade tensorflow to 2.2.0 and then downgrade keras 2.9.0 to 2.1.0 ; the error message is as follows:
AttributeError: tensorflow no module"get_default_session"
So the modification is as follows (in yolo.py):
After adding import tensorflow as tf # 20230224
, change the sentence below (the reason why it is not changed directly to import tensorflow.compat.v1 as tf is that some netizens said it will cause other errors)
self.sess = tf.compat.v1. keras.backend.get_session() #self.sess = K.get_session()
- After running, another error is prompted (in tensorflow_backend.py):
AttributeError: module ‘tensorflow’ has no attribute ‘get_default_graph’
AttributeError: module ‘tensorflow’ has no attribute ‘placeholder’
It is completely solved here, as follows: Reference
netizen: 45678
Import tensorflow as tf
is changed to the following two sentences:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
提示: 成功运行后Python3.7(tensorflow-gpu)下的相关软件 Keras-2.1.0 python3.7.9 tensorflow-2.2.0没用tensorflow-gpu: