2019-12-31: InsightFace project actual combat (1) Environment configuration, construction and testing

1. Project environment and configuration

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

  • View system version command: find /etc/ -name *-release, then cat release file path
  • View GPU version command: nvidia-smi
  • View the CUDA version command: cat /usr/local/cuda/version.txt
  • View the CUDNN version command: cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

Two, environment construction

In the command line mode under xshell, build cpu and gpu environments respectively.

(1) Create an environment named "tf-cpu-InsightFace" and "tf-gpu-InsightFace"

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

(2) Write the above environment into the kernel of jupyter notebook

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

(3) Install third-party libraries

1. Activate the corresponding environment in xshell command line mode:

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

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

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

2. Install tensorflow 1.14

  • gpu version installation: gpu environment construction must first install cuda and cudnn (note when installing cuda and cudnn: gpu graphics driver version, tensorflow-gpu version, cuda version and cudnn version must be adapted), and then install the gpu version tensorflow.
conda  install cuda==9.0
conda install cudnn
pip --default-timeout=100 install tensorflow-gpu==1.14
  • cpu version installation: pip --default-timeout=100 install tensorflow==1.14

3. Install mxnet:

  • GPU version installation: pip install mxnet-cu90
  • CPU version installation: pip install mxnet

4. Ensure that the scipy version is 1.2: pip install scipy==1.2

5. Install opencv: install opencv: pip install opencv-python

6、安装sklearn:pip install scikit-learn

7. Install easydict: pip install easydict

8. Install skimage: pip install scikit-image

Three, environmental testing

(1) tensorflow environment test

1. CPU environment test: In the xshell command line mode, enter the python environment and execute the "import tensorflow as tf" statement

2. GPU environment test:

### 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))

(Two) mxnet environment test

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())

 

Guess you like

Origin blog.csdn.net/weixin_38192254/article/details/103786925