1. 硬件環(huán)境
操作系統(tǒng): Windows 10
CPU:i7 8700k 3.7GHZ
GPU:Geforce GTX 1080ti
內(nèi)存: 8G
2. 文件目錄
3. 安裝步驟
- 安裝主板集成顯卡驅(qū)動(dòng)
下個(gè)驅(qū)動(dòng)精靈安裝即可,安裝驅(qū)動(dòng)完成后贴硫,再關(guān)機(jī)插入Geforce GTX 1080ti
- 安裝Geforce GTX 1080ti驅(qū)動(dòng)
1. 可以去nvida官網(wǎng)下載英遭,我下載的是388.43-desktop-win10-64bit-international-whql 2. 如果提示“此NVIDA驅(qū)動(dòng)程序不支持此操作系統(tǒng)類型” 原因是亦渗,windows 10操作系統(tǒng)版本太老的緣故法精,去“更新”里面更新下操作系統(tǒng)(如果你的版本很老,會(huì)耗時(shí)很長(zhǎng))
- 安裝Anaconda5.0.1 For Windows
Anaconda:https://www.continuum.io/downloads Python 3.6 version 64BIT INSTALLER:https://repo.continuum.io/archive/Anaconda3-5.0.1-Windows-x86_64.exe
- 安裝Tensorflow-gpu
conda install pip pip install --ignore-installed --upgrade tensorflow-gpu
- 添加系統(tǒng)環(huán)境變量PYTHONPATH
環(huán)境變量-->(系統(tǒng)變量下新建PYTHONPATH)加入以下內(nèi)容:C:\suredata\0bject-Detector-App;C:\suredata\0bject-Detector-App\slim
- 安裝vc_redist.x64.exe
由于tensorflow只支持CUDA8.0和CUDNN v6 版本辽装,所以要先裝拾积,要不然會(huì)有以下錯(cuò)誤:
安裝CUDA8.0 + cudnn6.0:ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
注意: 有的說(shuō)cudnn5.1也可以拓巧,但是我試了win10最新系統(tǒng)上一死,cudnn5.1不可以摘符,仍然提示上面錯(cuò)誤1. 安裝CUDA8.0 [下載地址](https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_win10-exe) 2. cudnn6.0 [下載地址](https://developer.nvidia.com/rdp/cudnn-download#a-collapse6-8) 3. 把解壓后的文件夾復(fù)制到CUDA8.0的安裝目錄文件夾內(nèi)逛裤。 默認(rèn)CUDA8.0的安裝目錄為:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0
3. 訓(xùn)練
- 管理員權(quán)限打開(kāi)cmd并執(zhí)行步驟2的命令開(kāi)始訓(xùn)練
1. cd C:\suredata\0bject-Detector-App 2. 執(zhí)行如下命令開(kāi)始訓(xùn)練:python object_detection\train.py --logoutstderr --train_dir=sd_train\ssd_model_2017_12_21\output --pipeline_config_path=sd_train\ssd_model_2017_12_21\ssd_mobilenet_v1_pascal.config
訓(xùn)練情況:
- 生成模型
訓(xùn)練完成后用下列命令生成可用模型:
如果出現(xiàn)以下錯(cuò)誤:python object_detection\export_inference_graph.py --input_type image_tensor --pipeline_config_path sd_train\ssd_model_2017_12_21\ssd_mobilenet_v1_pascal.config --trained_checkpoint_prefix sd_train\ssd_model_2017_12_21\output\model.ckpt-30000 --output_directory sd_train\ssd_model_2017_12_21\savedModel
可以通過(guò)將C:\suredata\0bject-Detector-App\object_detection\builders\post_processing_builder.py中的:C:\suredata\0bject-Detector-App>python object_detection\export_inference_graph.py --input_type image_tensor --pipeline_config_path sd_train\ssd_model_2017_12_21\ssd_mobilenet_v1_pascal.config --trained_checkpoint_prefix sd_train\ssd_model_2017_12_21\output\model.ckpt-30000 --output_directory sd_train\ssd_model_2017_12_21\savedModel Traceback (most recent call last): File "object_detection\export_inference_graph.py", line 119, in <module> tf.app.run() File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "object_detection\export_inference_graph.py", line 115, in main FLAGS.output_directory, input_shape) File "C:\suredata\0bject-Detector-App\object_detection\exporter.py", line 427, in export_inference_graph input_shape, optimize_graph, output_collection_name) File "C:\suredata\0bject-Detector-App\object_detection\exporter.py", line 353, in _export_inference_graph postprocessed_tensors = detection_model.postprocess(output_tensors) File "C:\suredata\0bject-Detector-App\object_detection\meta_architectures\ssd_meta_arch.py", line 405, in postprocess class_predictions_without_background) File "C:\suredata\0bject-Detector-App\object_detection\builders\post_processing_builder.py", line 94, in score_converter_fn scaled_logits = tf.divide(logits, logit_scale, name='scale_logits') File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py", line 309, in divide return DivideDelegateWithName(x, name) / y File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py", line 294, in __truediv__ return _truediv_python3(self.x, y, self.name) File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py", line 981, in _truediv_python3 (x_dtype, y_dtype)) TypeError: x and y must have the same dtype, got tf.float32 != tf.int32
修改為:def _score_converter_fn_with_logit_scale(tf_score_converter_fn, logit_scale): """Create a function to scale logits then apply a Tensorflow function.""" def score_converter_fn(logits): scaled_logits = tf.divide(logits, logit_scale, name='scale_logits') return tf_score_converter_fn(scaled_logits, name='convert_scores') score_converter_fn.__name__ = '%s_with_logit_scale' % ( tf_score_converter_fn.__name__) return score_converter_fn
再執(zhí)行生成模型命令:def _score_converter_fn_with_logit_scale(tf_score_converter_fn, logit_scale): """Create a function to scale logits then apply a Tensorflow function.""" def score_converter_fn(logits): cr = logit_scale cr = tf.constant([[cr]],tf.float32) scaled_logits = tf.divide(logits, cr, name='scale_logits') return tf_score_converter_fn(scaled_logits, name='convert_scores') score_converter_fn.__name__ = '%s_with_logit_scale' % ( tf_score_converter_fn.__name__) return score_converter_fn
可以看到問(wèn)題解決阳堕。
幾個(gè)問(wèn)題:
- GPU利用率始終上不去20%左右恬总,CPU80%
原因是: