2019-12-31: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"

conda create -n  tf-cpu-InsightFace python==3.6
conda create -n  tf-gpu-InsightFace python==3.6

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

python -m ipykernel install --name一 tf-cpu-InsightFace
python -m ipykernel install --name tf-gpu-InsightFace

(三)安装第三方库

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

## tf-cpu-InsightFace 环境激活
conda activate tf-cpu-InsightFace

## tf-gpu-InsightFace 环境激活
conda activate tf-gpu-InsightFace

## 查看所有环境
conda info --envs

2、安装tensorflow1.14

  • gpu版本安装:gpu环境搭建还要先安装cuda和cudnn(安装cuda和cudnn时要注意:gpu显卡驱动版本、tensorflow-gpu版本、cuda版本和cudnn版本之间要适配),再安装gpu版本的tensorflow。
conda  install cuda==9.0
conda install cudnn
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环境测试:

### GPU环境测试

import tensorflow as tf

with tf.device('/cpu:0'):
    a = tf.constant([1.0,2.0,3.0],shape=[3],name='a')
    b = tf.constant([1.0,2.0,3.0],shape=[3],name='b')

with tf.device('/gpu:1'):
    c = a+b
print(c)

sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True,log_device_placement=True))
sess.run(tf.global_variables_initializer())
print(sess.run(c))

(二)mxnet环境测试

import mxnet as mx
from mxnet import nd
from mxnet.gluon import nn

mx.cpu(), mx.gpu(), mx.gpu(0)

a = nd.array([1, 2, 3], ctx=mx.gpu())

猜你喜欢

转载自blog.csdn.net/weixin_38192254/article/details/103786925
今日推荐