先尝试尝试tensorflow
1. 修改/etc/hosts/ 加入如下行
#TensorFlow start
64.233.188.121 www.tensorflow.org
#TensorFlow end
2. 进入官网后有这些选项
- Pip install: Install TensorFlow on your machine, possibly upgrading previously installed Python packages. May impact existing Python programs on your machine.
- Virtualenv install: Install TensorFlow in its own directory, not impacting any existing Python programs on your machine.
- Anaconda install: Install TensorFlow in its own environment for those running the Anaconda Python distribution. Does not impact existing Python programs on your machine.
- Docker install: Run TensorFlow in a Docker container isolated from all other programs on your machine.
- Installing from sources: Install TensorFlow by building a pip wheel that you then install using pip.
3. Anaconda 安装
进入清华镜像 https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
进入下载页面 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
选择下载 Anaconda2-5.1.0-Linux-x86_64.sh
在控制台上进入下载后的文件目录, 默认~/Downloads/ 之下
执行
chmod +x Anaconda2-5.1.0-Linux-x86_64.sh
./Anaconda2-5.1.0-Linux-x86_64.sh
加入conda源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
3. 安装tensorflow
创建tensorflow虚拟环境
conda create -n tensorflow python=2.7
因为要使用GPU,使用PIP进行安装
$ source activate tensorflow
(tensorflow)$ # Your prompt should change
设定Binary安装路径
# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7
# Requires CUDA toolkit 8.0 and CuDNN v5. For other versions, see "Installing from sources" below.
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.0rc1-cp27-none-linux_x86_64.whl
安装 test flow
# Python 2
(tensorflow)$ pip install --ignore-installed --upgrade $TF_BINARY_URL
3. 激活GPU Support
1. 安装GTX 1060的驱动
参照:http://blog.csdn.net/shenqiongniujiahui/article/details/52745061
2. 安装CUDA
`sudo dpkg -i cuda-repo-ubuntu1604_8.0.61-1_amd64.deb`
`sudo apt-get update`
`sudo apt-get install cuda`
3.Download cuDNN 5.0
https://developer.nvidia.com/cudnn
tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz
sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
4. 添加如下的参数到.profile文件中
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda
4. 测试
激活tesorflow环境
source activate tensorflow
hello world!
$ python
...
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42
>>>
手写识别
进入下面这个命令的执行结果的目录
$ python -c 'import os; import inspect; import tensorflow; print(os.path.dirname(inspect.getfile(tensorflow)))'
执行
python -m tensorflow.models.image.mnist.convolutional