1. 程式人生 > >零基礎深度學習筆記3——Win7-Tensorflow-GPU安裝

零基礎深度學習筆記3——Win7-Tensorflow-GPU安裝

之前已經在另一臺電腦上安裝好了CPU版本的TF,

以為GPU版本的步驟什麼的應該也不難,沒想到還是有些坑要填。

清單:

系統:WIN7

python:3.5版本

CUDA:8.0

Cudnn:v6.0(這裡版本的選擇很重要!!!)

Tensorflow:1.3

下面說下安裝過程:

預設WIN7系統已經裝好了


下載完直接雙擊安裝就好了

二、安裝cuda8.0:

3.      安裝cuda8.0:雙擊cuda_8.0.61_windows.exe直接進行安裝即可,預設安裝到C:\ProgramFiles\NVIDIA GPU Computing Toolkit目錄下;

4.      驗證cuda8.0已正確安裝:

開啟cmd,輸入$ nvcc  -V,結果如下圖:


三、下載cudnn 6.0:

解壓後分別將cuda/include、cuda/lib、cuda/bin三個目錄中的內容拷貝到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0對應的include、lib、bin目錄下即可。

這裡一定要注意cudnn的版本要和自己的Tensorflow版本相匹配,否則會出現  “DLL load failed: 找不到指定的模組等各種報錯。

我原先下載的是7.0版本的,後面又查資料說要有cuDNN64_5.dll.就又下載了5.0的,但還是無法執行,後面幸虧找到了個篩查錯誤的程式,才發現要6.0版本的。如果你安裝完TF後,發現不能正常執行,可以試下這個篩查程式碼,如果都OK,請跳過

程式碼如下:

# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""A script for testing that TensorFlow is installed correctly on Windows.
The script will attempt to verify your TensorFlow installation, and print
suggestions for how to fix your installation.
"""

import ctypes
import imp
import sys

def main():
  try:
    import tensorflow as tf
    print("TensorFlow successfully installed.")
    if tf.test.is_built_with_cuda():
      print("The installed version of TensorFlow includes GPU support.")
    else:
      print("The installed version of TensorFlow does not include GPU support.")
    sys.exit(0)
  except ImportError:
    print("ERROR: Failed to import the TensorFlow module.")

  candidate_explanation = False

  python_version = sys.version_info.major, sys.version_info.minor
  print("\n- Python version is %d.%d." % python_version)
  if not (python_version == (3, 5) or python_version == (3, 6)):
    candidate_explanation = True
    print("- The official distribution of TensorFlow for Windows requires "
          "Python version 3.5 or 3.6.")
  
  try:
    _, pathname, _ = imp.find_module("tensorflow")
    print("\n- TensorFlow is installed at: %s" % pathname)
  except ImportError:
    candidate_explanation = False
    print("""
- No module named TensorFlow is installed in this Python environment. You may
  install it using the command `pip install tensorflow`.""")

  try:
    msvcp140 = ctypes.WinDLL("msvcp140.dll")
  except OSError:
    candidate_explanation = True
    print("""
- Could not load 'msvcp140.dll'. TensorFlow requires that this DLL be
  installed in a directory that is named in your %PATH% environment
  variable. You may install this DLL by downloading Microsoft Visual
  C++ 2015 Redistributable Update 3 from this URL:
  https://www.microsoft.com/en-us/download/details.aspx?id=53587""")

  try:
    cudart64_80 = ctypes.WinDLL("cudart64_80.dll")
  except OSError:
    candidate_explanation = True
    print("""
- Could not load 'cudart64_80.dll'. The GPU version of TensorFlow
  requires that this DLL be installed in a directory that is named in
  your %PATH% environment variable. Download and install CUDA 8.0 from
  this URL: https://developer.nvidia.com/cuda-toolkit""")

  try:
    nvcuda = ctypes.WinDLL("nvcuda.dll")
  except OSError:
    candidate_explanation = True
    print("""
- Could not load 'nvcuda.dll'. The GPU version of TensorFlow requires that
  this DLL be installed in a directory that is named in your %PATH%
  environment variable. Typically it is installed in 'C:\Windows\System32'.
  If it is not present, ensure that you have a CUDA-capable GPU with the
  correct driver installed.""")

  cudnn5_found = False
  try:
    cudnn5 = ctypes.WinDLL("cudnn64_5.dll")
    cudnn5_found = True
  except OSError:
    candidate_explanation = True
    print("""
- Could not load 'cudnn64_5.dll'. The GPU version of TensorFlow
  requires that this DLL be installed in a directory that is named in
  your %PATH% environment variable. Note that installing cuDNN is a
  separate step from installing CUDA, and it is often found in a
  different directory from the CUDA DLLs. You may install the
  necessary DLL by downloading cuDNN 5.1 from this URL:
  https://developer.nvidia.com/cudnn""")

  cudnn6_found = False
  try:
    cudnn = ctypes.WinDLL("cudnn64_6.dll")
    cudnn6_found = True
  except OSError:
    candidate_explanation = True

  if not cudnn5_found or not cudnn6_found:
    print()
    if not cudnn5_found and not cudnn6_found:
      print("- Could not find cuDNN.")
    elif not cudnn5_found:
      print("- Could not find cuDNN 5.1.")
    else:
      print("- Could not find cuDNN 6.")
      print("""
  The GPU version of TensorFlow requires that the correct cuDNN DLL be installed
  in a directory that is named in your %PATH% environment variable. Note that
  installing cuDNN is a separate step from installing CUDA, and it is often
  found in a different directory from the CUDA DLLs. The correct version of
  cuDNN depends on your version of TensorFlow:
  
  * TensorFlow 1.2.1 or earlier requires cuDNN 5.1. ('cudnn64_5.dll')
  * TensorFlow 1.3 or later requires cuDNN 6. ('cudnn64_6.dll')
    
  You may install the necessary DLL by downloading cuDNN from this URL:
  https://developer.nvidia.com/cudnn""")
    
  if not candidate_explanation:
    print("""
- All required DLLs appear to be present. Please open an issue on the
  TensorFlow GitHub page: https://github.com/tensorflow/tensorflow/issues""")

  sys.exit(-1)

if __name__ == "__main__":
  main()

新建一個tensorflow_self_check.py,然後用python執行就好了

我得到的結果如下,注意圈紅色的部分(TF1.2.1或者更早版本的要cudnn64_5.dll,也就是v5版本,但1.3及之後的要cudnn64_6.dll,也就是v6版本):


四、安裝Tensorflow

官網上有兩種安裝方法,一種是直接安裝,另一種是用Anaconda安裝,我用的是第一種

如果是隻有CPU輸入:pip3 install --upgrade tensorflow

     如果是有GPU的輸入:pip3 install --upgrade tensorflow-gpu

五、驗證是否已正確安裝TF

輸入

$ python
啟用python環境,然後輸入
>>>import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')>>> sess = tf.Session()>>>print(sess.run(hello))
如果能夠顯示
Hello, TensorFlow!
那就說明安裝成功啦!~~

參考網站:

https://www.tensorflow.org/install/install_windows

http://blog.csdn.net/fengbingchun/article/details/53892997

https://gist.github.com/mrry/ee5dbcfdd045fa48a27d56664411d41c#file-tensorflow_self_check-py

相關推薦

基礎深度學習筆記3——Win7-Tensorflow-GPU安裝

之前已經在另一臺電腦上安裝好了CPU版本的TF, 以為GPU版本的步驟什麼的應該也不難,沒想到還是有些坑要填。 清單: 系統:WIN7 python:3.5版本 CUDA:8.0 Cudnn:v6.0(這裡版本的選擇很重要!!!) Tensorflow:1.3 下面說下

深度學習筆記win7TensorFlow安裝

轉載自http://blog.csdn.net/hola_f/article/details/70482300 最近要學習神經網路相關的內容,所以需要安裝TensorFlow。不得不說,安裝TensorFlow的感受就像是大一剛入學學習C語言時,安裝vs時一樣,問題一大堆,工具都裝不好,

深度學習筆記3-優化函式

深度學習筆記3-優化函式 深度學習的優化演算法有隨機梯度下降法(SGD)、標準梯度下降法(BGD)、小批量梯度下降法(MBGD)、Momentum梯度優化(SGDM)、Adagrad、RMSprop、Adam等等演算法。SGD、BGD、MBGD很好理解,且在感知機那一節也有簡述,不再介紹

吳恩達深度學習筆記3-Course1-Week3【淺層神經網路】

淺層神經網路: 一、淺層神經網路的表示 本文中的淺層神經網路指的是 two layer nn 即 one input layer + one hidden layer + one output layer。通常計算神經網路的層數不包括 input l

一、深度學習之anaconda以及Tensorflow安裝

1.anaconda安裝 注意:將兩個選項都勾選上,將安裝路徑寫入環境變數 2.安裝Tensorflow (1) 建立一個 conda 計算環境名字叫tensorflow:           conda create -n tensorflow pyth

PyTorch學習筆記(3)—CPU和GPU上載入模型

前言 有一些現實的問題是這樣的:當我們在GPU叢集或者伺服器上訓練模型的時候,有時候需要將模型取回,在本地測試一下。這個時候就需要PyTorch將模型轉換為cpu的版本,因為PyTorch針對不同的系統和cuda有不同的版本。因此無法直接將GPU訓練出的

keras學習筆記3——Merge、GPU呼叫、快速開始及常見問題

1. Merge層 Merge層主要是用來合併多個model的,例子如下: from keras.layers import Merge,Dense from keras.models import Sequential first_model=Sequ

linux基礎學習筆記3

一、系統狀態檢測命令 1、ifconfig命令 interface config eno1677728:網絡卡名稱 inet 192.168.10.10 :ip地址 RX:收到資料        TX:傳送資料 2、uname命令 unix name 檢視系統核心

基礎大資料HADOOP學習-筆記3-HDFS特點

HDFS的特點 優點: 1)處理超大檔案   這裡的超大檔案通常是指百MB、數百TB大小的檔案。目前在實際應用中,   HDFS已經能用來儲存管理PB級的資料了。

基礎大資料HADOOP學習-筆記3-安全模式 safemode

【安全模式 safemode】 3種方式 方式一:Namenode的一種狀態,啟動時會自動進入安全模式,在安全模式,檔案系統不 允許有任何修改,“只讀不寫”。目的,是在系統啟動時檢查各個DataNod

tensorflow學習筆記(3)前置數學知識

標簽 fit orm 特征 dmi TP inf tdd Coding               tensorflow學習筆記(3)前置數學知識 首先是神經元的模型 接下來是激勵函數 神經網絡的復雜度計算 層數:隱藏層+輸出層 總參數=總的w+b 下圖為2層 如下圖

C++學習筆記3 - 基礎數據類型

小寫 本質 div c++ 常見 國家 沒有 標點符號 基礎 #include <iostream> //基礎數據類型 /* C++ 數據類型包括 1)基礎數據類型 2)復合數據類型 3)指針類 4)引用類 基礎數據類型一共13種 布爾型

sklearn 學習筆記-3 機器學習理論基礎

本章主要知識點: 過擬合和欠擬合的概念 模型的成本及成本函式的含義 評價一個模型的好壞的標準 學習曲線,以及用學習曲線來對模型進行診斷 通用模型優化方法 其他模型評價標準 ##3.1過擬合和欠擬合 過擬合就是模型能很好的擬合訓練樣

Tensorflow學習筆記(3)

深層神經網路,目前TensorFlow提供了7種不同的非線性啟用函式, tf.nn.relu 、tf.sigrnoid和tf.tanh是其中比較常用的幾個。當然,TensorFlow 也支援使用自己定義的啟用函式 。簡單eg:異或運算(同為0,異為1) 通過神經網路解決多分類問題最常用的

吳恩達深度學習筆記3)-神經網路如何實現監督學習

神經網路的監督學習(Supervised Learning with Neural Networks) 關於神經網路也有很多的種類,考慮到它們的使用效果,有些使用起來恰到好處,但事實表明,到目前幾乎所有由神經網路創造的經濟價值,本質上都離不開一種叫做監督學習的機器學習類別,讓我們舉例看看。

第009講:了不起的分支和迴圈3 | 學習記錄(小甲魚基礎入門學習Python)

(標答出處: 魚C論壇) 《零基礎入門學習Python》 基礎題: 0、下面的迴圈會列印多少次"I Love FishC"? for i in range(0, 10, 2): print(‘I Love FishC’) (0,2,4,6,8)共5次 1、下面的迴圈會列

深度學習,周志華,機器學習,西瓜書,TensorFlow,Google,吳軍,數學之美,李航,統計學習方法,吳恩達,深度學習筆記,pdf下載

1. 機器學習入門經典,李航《統計學習方法》 2. 周志華的《機器學習》pdf 3.《數學之美》吳軍博士著pdf 4. Tensorflow 實戰Google深度學習框架.pdf 5.《TensorFlow實戰》黃文堅 高清完整PDF  6. 復旦大

Java核心技術 卷I 基礎知識 學習筆記3

參考:Java核心技術 卷I 基礎知識 類之間最常見的關係有:依賴、聚合、繼承 依賴即“use-a”關係,是一種最明顯的,最常見的關係。如果一個類的方法操作另一個類的物件,就說一個類依賴於另一個類。應該儘可能地將相互依賴的類減至最少。 聚合即“has-a”關係,是一種具體且

AS3 0基礎學習筆記 3 認識類結構

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

Tensorflow深度學習筆記(二)--BPNN手寫數字識別視覺化

資料集:MNIST 啟用函式:Relu 損失函式:交叉熵 Optimizer:AdamOptimizer 視覺化工具:tensorboad 迭代21epoch,accuracy結果如下: Iter 16,Testing Accuracy: