赞
踩
一、项目环境及配置
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
二、环境搭建
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
- conda install cuda==9.0
- conda install cudnn
- pip --default-timeout=100 install tensorflow-gpu==1.14
3、安装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))
-
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
(二)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())
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。