--------------------------------------------------------------------------- InvalidArgumentError Traceback (most recent call last) <ipython-input-11-4c89a4180744> in <module>() 7 image_np_expanded = np.expand_dims(image_np, axis=0) 8 # Actual detection. ----> 9 output_dict = run_inference_for_single_image(image_np, detection_graph) 10 # Visualization of the results of a detection. 11 vis_util.visualize_boxes_and_labels_on_image_array( <ipython-input-10-3f18aee9e6d8> in run_inference_for_single_image(image, graph) 33 # Run inference 34 output_dict = sess.run(tensor_dict, ---> 35 feed_dict={image_tensor: np.expand_dims(image, 0)}) 36 37 # all outputs are float32 numpy arrays, so convert types as appropriate /home/cc/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in run(self, fetches, feed_dict, options, run_metadata) 887 try: 888 result = self._run(None, fetches, feed_dict, options_ptr, --> 889 run_metadata_ptr) 890 if run_metadata: 891 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr) /home/cc/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in _run(self, handle, fetches, feed_dict, options, run_metadata) 1118 if final_fetches or final_targets or (handle and feed_dict_tensor): 1119 results = self._do_run(handle, final_targets, final_fetches, -> 1120 feed_dict_tensor, options, run_metadata) 1121 else: 1122 results = [] /home/cc/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata) 1315 if handle is None: 1316 return self._do_call(_run_fn, self._session, feeds, fetches, targets, -> 1317 options, run_metadata) 1318 else: 1319 return self._do_call(_prun_fn, self._session, handle, feeds, fetches) /home/cc/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in _do_call(self, fn, *args) 1334 except KeyError: 1335 pass -> 1336 raise type(e)(node_def, op, message) 1337 1338 def _extend_graph(self): InvalidArgumentError: NodeDef mentions attr 'identical_element_shapes' not in Op<name=TensorArrayV3; signature=size:int32 -> handle:resource, flow:float; attr=dtype:type; attr=element_shape:shape,default=<unknown>; attr=dynamic_size:bool,default=false; attr=clear_after_read:bool,default=true; attr=tensor_array_name:string,default=""; is_stateful=true>; NodeDef: Preprocessor/map/TensorArray = TensorArrayV3[clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=<unknown>, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/device:GPU:0"](Preprocessor/map/TensorArrayUnstack/strided_slice). (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.). [[Node: Preprocessor/map/TensorArray = TensorArrayV3[clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=<unknown>, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/device:GPU:0"](Preprocessor/map/TensorArrayUnstack/strided_slice)]]
網上查了下:
這是一種向前兼容性錯誤,通常在使用比用於編譯服務器的代碼更新的代碼來訓練模型時發生(並且兩者之間存在前向不兼容的變化)。
所以我查看下自己tensorflow的版本:
import tensorflow as tf print tf.__version__
顯示是1.4.1,所以我決定要升級一下:
pip install --upgrade --ignore-installed tensorflow-gpu
悲劇了,安裝完后運行
import tensorflow as tf
提示: libcublas.so.9.0: cannot open shared object file: No such file or directory ??!!!!
然后在這里看到這樣的回復:
For tensorflow 1.5 you must have installed the Cuda 9.0 and for tensorflow 1.4 you must use cuda 8.0. If the the tensorflow version and cuda version are compatible, then check the environment variables i.e. CUDA_HOMEand LD_LIBRARY_PATH.
現在又讓我把版本退回到1.4去:
pip install --upgrade tensorflow-gpu==1.4WTH??!!
請教了師兄后,確實是需要升級tensorflow.所以接下來就是要升級對應的cuda9.0
首先從官網上下載了 cuda_9.0.176_384.81_linux.run 進行安裝
直接安裝會報錯:you appear to be running an x server pleaseexit x before installing 所以先是ctrl+alt+F1進入命令行 >>sudo service lightdm stop >>sudo init 3 >>cd Download >>sudo sh cuda_9.0.176_384.81_linux.run
進入安裝過程,需要注意,我已經安裝過顯卡驅動了,所以在安裝過程中,第二個問題是否安裝NVIDIA DRIVER選擇 N !!!!
下面就是選擇安裝cuda toolkit
結束安裝后 sudo service lightdm start 重新回到窗口界面下.此時 import tensorflow as tf 依舊會報錯,原因是cuda9.0的路徑以及對應的cudnn7.0還沒配置.
檢查到是因為/etc/ld.so.conf.d文件夾下,有cuda.conf和 cuda-8-0.conf兩個文件中路徑還是指向的cuda8.0 所以修改之后就可以了.
