TensorFlow + FaceNet + GPU training model (ultra-detailed process) (C, GPU configuration)

ok, fine, and finally to the most critical moment, and configuration GPU

GPU is what I think the stuff Needless to say, as long as it can let you know Gods step in computer vision tasks legendary stage props on the line, but the burst rate is very low, maybe only 1% ...

Cuda, Cudnn, Baidu search these two are basically content, then for me to answer questions burst rate:

1.50% of the players after seeing the configuration process written by someone else, you can abandon

2.40% of the players in the process of trying to configure, various Bug, then frustrated, trying to say invoices ring smashed computer

3. The remaining 9% of the players, they only recently from the pinnacle of the throne of the crowd, after untold hardships, and then successfully installed Cuda and Cudnn, after install tensorflow-gpu, import tensorflow no error. In the pinnacle of life on the occasion, they had a question, and why my data was calculated on the CPU? ? ? Louzhu pro-test your method I have a problem ah! (Blackening the comments section Killer)

In fact, the above we talked about so much, or want to emphasize that the importance of the release. For example, assume that Lu Xun reborn today, you took to write their own articles, please sir help you review, this time Master Lu will return to you one: What is this stuff?

Causes it? Lu Xun is the traditional characters of that era with the results you come to a Simplified Chinese, this not Zhaoma.

Depth learning framework version too, need to find resources that era corresponding job.

In TensorFlow official website, we can clearly see each version corresponds to the version of Python and Cuda, Cudnn version.

https://tensorflow.google.cn/

According to this table shows, our TensorFlow version is 1.7.0, so it should be corresponding Cuda 9, Cudnn seven fishes.

Louzhu pro-test can be installed Cuda10, but in the end GPU is invalid, then into the topic.

CUDA installation

Official website: https://developer.nvidia.com/cuda-toolkit

To the official website to find CUDA9.0 installation package, and download

Likewise, friendship links provided Baidu Cloud

链接:https://pan.baidu.com/s/1EjSo84ie38boYnUYeS3c1A

提取码:cp3b

精简和自定义安装皆可,默认安装就行,如果想要修改路径的话,需要将路径加入系统环境中,做不到的小盆友就老老实实的默认安装吧。

在终端中输入nvcc -V,出现以下内容就代表安装成功了

cuDNN安装 

cuDNN是CUDA必要的驱动文件,可在官网直接下载

https://developer.nvidia.com/rdp/cudnn-archive

很直观的可以看到,我们安装的CUDA版本是9.0,所以只有下载对应的cuDNN就好了。

然后吧,如果您下载了最新版本的,譬如我列举出的7.6.4版本的话,我只想说一句,孩子,你没救了,看到什么新就想要什么,这什么毛病啊...

很负责的告诉你,这里躺着一个大坑,没错,我们需要cuDNN7版本的,但是,是7.0的!!!

在上述的百度云链接中,我已经把对应版本的都放进去了,直接下载即可,当然也可以挑战外网的速度。

下载完解压后子目录有三个文件夹,接下来打开刚刚CUDA的安装路径

默认的话路径是C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0

把cuDNN的文件拷贝到CUDA中,注意lib是子目录下x64的文件,接着在系统环境下添加lib\x64目录

这样理论上就安装好了,接下来就是测试环节

测试GPU

在之前的Python环境安装中,我们安装的tensorflow是cpu版本的,所以要卸载了重新安装gpu版本的框架

首先在命令行中输入pip uninstall -y tensorflow

接着输入 pip install tensorflow-gpu==1.7.0

测试成功,接下来就开始愉快的GPU之旅吧

使用GPU进行数据预处理

编辑align_dataset_mtcnn.py文件,移至第54行

sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))

修改为

config = tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False, allow_soft_placement=True)
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)

不要忘了在虚拟环境中也更替此文件

接着输入预处理训练集的命令

python src/align/align_dataset_mtcnn.py datasets/vggface2/train/ datasets/vggface2/train_182 --image_size 182 --margin 44

运行成功后打开任务管理器或者在终端中查看GPU的使用情况

 

成功!!!

下一章将介绍利用处理好的训练集进行模型训练,并在lfw数据集上进行验证 

 

发布了116 篇原创文章 · 获赞 7 · 访问量 5980

Guess you like

Origin blog.csdn.net/qq_40204582/article/details/104100734