安裝環境:
- Windows 10 64bit
- GPU: GeForce gt 720
- Python: 3.5.3
- CUDA: 8
- 首先下載Anaconda3的Win10 64bit版,安裝Python3.5版本。因為目前TensorFlow對Windows只支持Python3.5。可以直接下載Anaconda的安裝包安裝即可,一般不會有問題。(清華鏡像https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/)
- TensorFlow 有兩個版本:CPU 版本和 GPU 版本。GPU 版本需要 CUDA 和 cuDNN 的支持,CPU 版本不需要。如果你要安裝 GPU 版本,請先確認你的顯卡支持 CUDA。我安裝的是 GPU 版本,采用 pip 安裝方式,所以就以 GPU 安裝為例,CPU 版本只不過不需要安裝 CUDA 和 cuDNN。參考文獻1)中有詳細記錄。
- 安裝cuda8.0(https://developer.nvidia.com/cuda-downloads)(2)中提到CUDA的安裝組件,果然發現,在安裝CUDA的過程中,安裝包自身就包括了一個369.30版的顯卡驅動。那么這個版本就應該是和CUDA8相互支持匹配的驅動程序。)
- 安裝cudnn5.1(https://developer.nvidia.com/cudnn)解壓剛才下下來的安裝包,將這三個文件夾下的文件拷到CUDA對應的文件夾下面即可
- Anaconda安裝完成后,直接在Windows的命令窗口里敲Python就應該能看到版本是否是3.5。
- 創建tensorflow虛擬環境 C:> conda create -n tensorflow python=3.5,今后所有的東西都需要在該虛擬環境里進行,包括安裝各種包和keras
- 激活虛擬環境 C:> activate tensorflow
- To install the GPU version of TensorFlow, enter the following command (on a single line):(tensorflow)C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.2.0-cp35-cp35m-win_amd64.whl
- 安裝keras 在tensorflow虛擬環境里面,pip install keras
- 報錯,安裝scipy失敗,只能單獨安裝scipy
- 使用pip list查看哪幾個包沒有安裝成功,結果就缺少scipy,這一步好像keras需要安裝包括numpy和wheel在內的幾個包,報錯scipy安裝失敗
- 仍然在tensorflow虛擬環境里面,進入python如下圖
- 輸入import pip 和 print(pip.pep425tags.get_supported()),查看包的依賴性
- 在www.lfd.uci.edu/%7Egohlke/pythonlibs/上找到相應的whl文件,下載到本地,注意依賴信息,cp35,cp35,mwin_amd64在上述網址找到相應的文件:numpy-1.13.0+mkl-cp35-cp35m-win_amd64.whl和scipy-0.19.0-cp35-cp35m-win_amd64.whl
- 即使你在此前已經安裝過numpy,也請從該頁面中找到numpy+mkl的whl,下載到本地,因為重點在於mkl而不是numpy。
- 把兩個包拷貝到當前路徑,如筆者就拷貝到c:\Users\Alexander文件夾下
- 安裝這兩個文件,如圖
- 然后就可以安裝keras了
- 測試一下:
- 然后測試一下tensorflow,用官網上的就行。
Invoke python from your shell as follows:
$ python
Enter the following short program inside the python interactive shell:>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
If the system outputs the following, then you are ready to begin writing TensorFlow programs:Hello, TensorFlow!
這些命令也需要在tensorflow虛擬環境里面運行。
下一步就可以測試mnist數據集了。
1)https://www.tensorflow.org/install/install_windows
2)http://blog.csdn.net/infovisthinker/article/details/54705826
3)http://jingyan.baidu.com/article/ca41422f27c56a1eae99ed39.html
4)https://keras.io/
還有幾篇也有參考
http://www.cnblogs.com/lyy-totoro/p/6433626.html
https://blog.csdn.net/allyli0022/article/details/52131751
http://blog.csdn.net/sb19931201/article/details/53648615
http://developer2.download.nvidia.com/compute/machine-learning/cudnn/secure/v5.1/prod/doc/cudnn_install.txt?uB-MUhP4jAS6ZSEwLt7IT5AIDEb9zkBL3TZ10b2coenVnCBDM9LPZmV00tYAVZ7ayjzT_jH93R9uf5qMP9afMLRLgZPM_Fbex-1wmnmam3-AEytYJn2gAiQ8vBJfzQyBbQzZQuHFHGGvpIfKRqDAiCFKZWuUr9INBEwtf26JqOOiNZ56
http://www.tensorfly.cn/tfdoc/get_started/introduction.html