期末作業最後一天,實驗總算有點進展,記錄下配置過程
環境
- 項目地址:https://github.com/tinghuiz/SfMLearner
- GPU:GTX 950M
- 系統: Win 10
- python:3.5
建議使用conda 創建虛擬環境 - tensorflow-gpu:1.2.1
pip install tensorflow-gpu==1.2.1 -i https://mirrors.aliyun.com/pypi/simple/
項目主頁標的1.0,直接安裝1.0會報錯:ValueError: 'image' must be three-dimensional....
- cuda:8.0.61 win10
官網下載不了,點擊下載總是一個42B大小的損壞文件,所以最後直接找網盤下載 - cudnn:5.1
最開始安裝了6.0,報錯:Could no t load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found...
原來又是版本不對,雖然6.0也是對應cuda8.0,但是不對應tensorflow-gpu:1.2.1 - numpy:1.16.4
- scipy: 1.2.1
記錄中提到的一些文件:
數據集、cuda、cudnn、和深度估計預訓練模型
鏈接:https://pan.baidu.com/s/19ht5kgVL3ykfFM6hZurcuw
提取碼:phzi
測試Demo
測試Demo其實不用安裝gpu版本tensorflow,安裝對應版本的cpu版本就行
下載預訓練模型
在腳本中可以看到地址:http://people.eecs.berkeley.edu/~tinghuiz/projects/SfMLearner/models/kitti_depth_model.tar
有時候網絡會打不開,切換下別的網絡試一試,我換成學校網絡倒是可以下載了
Demo
用jupyter打開demo.ipynb
jupyter就直接conda或者pip安裝,然後輸入jupyter notebook
,就會起點web服務
打開demo.ipynb
運行第一段就報錯:
改成 fh = open('misc/sample.png', 'rb')
然後運行
試一試換monodepth2裏的示例圖:
效果不太好啊
這是monodepth2跑出來的結果:
數據集下載
使用的kiiti,raw data
百度網盤:
預處理
目錄結構:
運行預處理程序
python data/prepare_train_data.py --dataset_dir=data/kitti/dataset/ --dataset_name='kitti_raw_eigen' --dump_root=data/resulting/formatted/data/ --seq_length=3 --img_width=416 --img_height=128 --num_threads=4
訓練
出現: The TensorFlow library wasnt compiled to use SSE instructions,...
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
具體原因不知道
查看tensorflow-gpu是否正常使用gpu
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
print(tf.test.is_gpu_available())
>>> import tensorflow as tf
>>> import os
>>> os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
>>> print(tf.test.is_gpu_available())
2020-06-27 10:34:18.152335: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 950M, pci bus id: 0000:01:00.0)
True
直接運行出現: The TensorFlow library wasnt compiled to use SSE instructions,...
提示,然後在train.py增加
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
然後又會提示內存不夠…
2020-06-27 10:36:29.234645: E c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\stream_executor\cuda\cuda_driver.cc:924] failed to allocate 160.63M (168433920 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
...
...
嘗試把jupyter關了,多餘命令行窗口關了,(實在不行就重啓電腦),然後電腦就行了。
訓練過程:
C:\ProgramData\Miniconda3\envs\SfMLearner\python.exe C:/Users/59610/Desktop/AI/Code/cnn/SfMLearner/train.py --dataset_dir=data/kitti/resulting/formatted/data/ --checkpoint_dir=/where/to/store/checkpoints/ --img_width=416 --img_height=128 --batch_size=4
{'batch_size': 4,
'beta1': 0.9,
'checkpoint_dir': '/where/to/store/checkpoints/',
'continue_train': False,
'dataset_dir': 'data/kitti/resulting/formatted/data/',
'explain_reg_weight': 0.0,
'img_height': 128,
'img_width': 416,
'init_checkpoint_file': None,
'learning_rate': 0.0002,
'max_steps': 200000,
'save_latest_freq': 5000,
'seq_length': 3,
'smooth_weight': 0.5,
'summary_freq': 100}
Trainable variables:
depth_net/cnv1/weights:0
depth_net/cnv1/biases:0
depth_net/cnv1b/weights:0
depth_net/cnv1b/biases:0
depth_net/cnv2/weights:0
depth_net/cnv2/biases:0
depth_net/cnv2b/weights:0
depth_net/cnv2b/biases:0
depth_net/cnv3/weights:0
depth_net/cnv3/biases:0
depth_net/cnv3b/weights:0
depth_net/cnv3b/biases:0
depth_net/cnv4/weights:0
depth_net/cnv4/biases:0
depth_net/cnv4b/weights:0
depth_net/cnv4b/biases:0
depth_net/cnv5/weights:0
depth_net/cnv5/biases:0
depth_net/cnv5b/weights:0
depth_net/cnv5b/biases:0
depth_net/cnv6/weights:0
depth_net/cnv6/biases:0
depth_net/cnv6b/weights:0
depth_net/cnv6b/biases:0
depth_net/cnv7/weights:0
depth_net/cnv7/biases:0
depth_net/cnv7b/weights:0
depth_net/cnv7b/biases:0
depth_net/upcnv7/weights:0
depth_net/upcnv7/biases:0
depth_net/icnv7/weights:0
depth_net/icnv7/biases:0
depth_net/upcnv6/weights:0
depth_net/upcnv6/biases:0
depth_net/icnv6/weights:0
depth_net/icnv6/biases:0
depth_net/upcnv5/weights:0
depth_net/upcnv5/biases:0
depth_net/icnv5/weights:0
depth_net/icnv5/biases:0
depth_net/upcnv4/weights:0
depth_net/upcnv4/biases:0
depth_net/icnv4/weights:0
depth_net/icnv4/biases:0
depth_net/disp4/weights:0
depth_net/disp4/biases:0
depth_net/upcnv3/weights:0
depth_net/upcnv3/biases:0
depth_net/icnv3/weights:0
depth_net/icnv3/biases:0
depth_net/disp3/weights:0
depth_net/disp3/biases:0
depth_net/upcnv2/weights:0
depth_net/upcnv2/biases:0
depth_net/icnv2/weights:0
depth_net/icnv2/biases:0
depth_net/disp2/weights:0
depth_net/disp2/biases:0
depth_net/upcnv1/weights:0
depth_net/upcnv1/biases:0
depth_net/icnv1/weights:0
depth_net/icnv1/biases:0
depth_net/disp1/weights:0
depth_net/disp1/biases:0
pose_exp_net/cnv1/weights:0
pose_exp_net/cnv1/biases:0
pose_exp_net/cnv2/weights:0
pose_exp_net/cnv2/biases:0
pose_exp_net/cnv3/weights:0
pose_exp_net/cnv3/biases:0
pose_exp_net/cnv4/weights:0
pose_exp_net/cnv4/biases:0
pose_exp_net/cnv5/weights:0
pose_exp_net/cnv5/biases:0
pose_exp_net/pose/cnv6/weights:0
pose_exp_net/pose/cnv6/biases:0
pose_exp_net/pose/cnv7/weights:0
pose_exp_net/pose/cnv7/biases:0
pose_exp_net/pose/pred/weights:0
pose_exp_net/pose/pred/biases:0
parameter_count = 33187568
Epoch: [ 1] [ 100/ 1208] time: 0.6989/it loss: 0.967
Epoch: [ 1] [ 200/ 1208] time: 0.6371/it loss: 1.032
...
...
...