TensorFlow的安装与CNN测试
0.说明
在Google开源该框架之后便使用真实K40m卡测试,由于生产环境是CentOS6.6的操作系统,但是该框架需要在Python2.7环境下执行,CentOS6.6下折腾了一天没搞定,后来换成CentOS7,顺利跑通
1.系统环境
- python >=2.7
- numpy >=1.9
- gcc >=4.8.2
- cuda 7.0
- java >=1.8
- cudnn 6.5 v2
2.安装部署
#安装依赖,kernel-devel是为了安装cuda
yum -y install gcc python-devel kernel-devel
#安装pip
wget --no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz
tar zvxf 1.5.5.tar.gz
cd pip-1.5.5/
python setup.py install
#安装tensorflow,此时确保服务器可以联网,会自动下载安装numpy和six
pip install http://dlp.iflytek.com/soft/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
3.测试用例CNN
- 下载训练数据集
wget http://dlp.iflytek.com/soft/cifar-10-binary.tar.gz
tar -zxvf -C /tmp/cifar10_data
-
执行脚本(默认cpu)
cd /root/tensorflow-master/tensorflow/models/image/cifar10
python cifar10_train.py -
采用gpu执行
python cifar10_multi_gpu_train.py --num_gpus=4
4.脚本相关说明
#查看帮助
python cifar10_train.py --help
--batch_size BATCH_SIZE #一批数据的图片数量,默认是包含128个examples
Number of images to process in a batch.
--data_dir DATA_DIR #训练数据集目录,默认是/tmp/cifar10_data
Path to the CIFAR-10 data directory.
--train_dir TRAIN_DIR #训练目录
Directory where to write event logs and checkpoint.
--max_steps MAX_STEPS #最大步数,默认是1000000
Number of batches to run.
--log_device_placement LOG_DEVICE_PLACEMENT
Whether to log device placement.
--nolog_device_placement
Tutorials and Machine Learning Examples — TensorFlow
http://tensorflow.org/tutorials/deep_cnn/index.md