当前位置:   article > 正文

2019-12-31:InsightFace项目实战(一)环境配置、搭建和测试_insightface库安装

insightface库安装

一、项目环境及配置

CentOS Linux release 7.6.1810 (Core) + 2*GeForce GTX 1080ti + Python3.6.0 + Anaconda3 + Tensorflow1.14-gpu + CUDA  9.0.176 + CUDNN 7.6.4

  • 查看系统版本命令:find /etc/ -name *-release,然后 cat release文件路径
  • 查看GPU版本命令:nvidia-smi
  • 查看CUDA版本命令:cat /usr/local/cuda/version.txt
  • 查看CUDNN版本命令:cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

二、环境搭建

xshell下命令行方式,分别搭建cpu和gpu环境。

(一)创建名为”tf-cpu-InsightFace“的环境和"tf-gpu-InsightFace"

  1. conda create -n tf-cpu-InsightFace python==3.6
  2. conda create -n tf-gpu-InsightFace python==3.6

(二)将上述环境写入jupyter notebook的kernel中

  1. python -m ipykernel install --name一 tf-cpu-InsightFace
  2. python -m ipykernel install --name tf-gpu-InsightFace

(三)安装第三方库

1、xshell命令行模式下激活对应环境:

  1. ## tf-cpu-InsightFace 环境激活
  2. conda activate tf-cpu-InsightFace
  3. ## tf-gpu-InsightFace 环境激活
  4. conda activate tf-gpu-InsightFace
  5. ## 查看所有环境
  6. conda info --envs

2、安装tensorflow1.14

  • gpu版本安装:gpu环境搭建还要先安装cuda和cudnn(安装cuda和cudnn时要注意:gpu显卡驱动版本、tensorflow-gpu版本、cuda版本和cudnn版本之间要适配),再安装gpu版本的tensorflow。
  1. conda install cuda==9.0
  2. conda install cudnn
  3. pip --default-timeout=100 install tensorflow-gpu==1.14
  • cpu版本安装:pip --default-timeout=100 install tensorflow==1.14

3、安装mxnet:

  • GPU版本安装:pip install mxnet-cu90
  • CPU版本安装:pip install mxnet

4、保证scipy版本为1.2:pip install scipy==1.2

5、安装opencv:安装opencv:pip install opencv-python

6、安装sklearn:pip install scikit-learn

7、安装easydict:pip install easydict

8、安装skimage:pip install scikit-image

三、环境测试

(一)tensorflow环境测试

1、cpu环境测试:xshell命令行模式下,进入python环境,执行”import tensorflow as tf“语句

2、gpu环境测试:

  1. ### GPU环境测试
  2. import tensorflow as tf
  3. with tf.device('/cpu:0'):
  4. a = tf.constant([1.0,2.0,3.0],shape=[3],name='a')
  5. b = tf.constant([1.0,2.0,3.0],shape=[3],name='b')
  6. with tf.device('/gpu:1'):
  7. c = a+b
  8. print(c)
  9. sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True,log_device_placement=True))
  10. sess.run(tf.global_variables_initializer())
  11. print(sess.run(c))

(二)mxnet环境测试

  1. import mxnet as mx
  2. from mxnet import nd
  3. from mxnet.gluon import nn
  4. mx.cpu(), mx.gpu(), mx.gpu(0)
  5. a = nd.array([1, 2, 3], ctx=mx.gpu())

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/289284
推荐阅读
相关标签
  

闽ICP备14008679号