WIN10+RTX2070 tensorflow-gpu環境搭建

參考

tensorflow-windows-wheel 我選擇了:1.12.0\py37\GPU\cuda100cudnn73sse2python

前置環境

  • Visual Studio 2017
  • Anaconda3
這兩個我都安裝的最新版。
Visual Studio 2017不裝會致使安裝CUDA時"Visual Studio Integration"組件安裝失敗,我在此處卡了幾天,查了好多資料都無效。

GPU相關軟件下載

安裝

  • 顯卡驅動安裝
  • 安裝CUDA
安裝好以後的環境變量默認包含:
CUDA_PATH:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0
CUDA_PATH_V10_0:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0
PATH:
	C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin
	C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\libnvvp
	C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\extras\CUPTI\libx64(這個須要本身添加)
  • 安裝cuDNN
解壓cuDNN後獲得bin、include、lib三個文件夾
將bin下的cudnn64_7.dll拷貝到:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin
將include下的cudnn.h拷貝到:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include
將lib\x64下的cudnn.lib拷貝到:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib\x64

tensorflow-gpu環境配置

  • 打開
  • 建立環境
    conda create -n tensorflow_gpu_1.12_py37 python=3.7
  • 激活環境
    conda activate tensorflow_gpu_1.12_py37
  • 安裝tensorflow-gpu
    pip install E:\Downloads\tensorflow_gpu-1.12.0-cp37-cp37m-win_amd64.whl
  • 測試
    進入python
    	>>> import tensorflow as tf
    	>>> hello = tf.constant('Hello, tensorflow!')
    	>>> sess = tf.Session()
    輸出:
    2019-03-02 09:37:52.875467: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
    	2019-03-02 09:37:53.200917: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 0 with properties:name: GeForce RTX 2070 major: 7 minor: 5 memoryClockRate(GHz): 1.62
    	pciBusID: 0000:01:00.0
    	totalMemory: 8.00GiB freeMemory: 6.59GiB
    	2019-03-02 09:37:53.207587: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
    	2019-03-02 09:40:52.845289: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
    	2019-03-02 09:40:52.848702: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988]      0
    	2019-03-02 09:40:52.850105: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0:   N
    	2019-03-02 09:40:52.854219: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow 
    	device (/job:localhost/replica:0/task:0/device:GPU:0 with 6331 MB memory) -> physical GPU (device: 0, 
    	name: GeForce RTX 2070, pci bus id: 0000:01:00.0, compute capability: 7.5)
    接着執行
    print(sess.run(hello))
    輸出:
    b'Hello, tensorflow!'
    關閉session
    sess.close()

至此結束,第一次感受開發環境搭建不容易。git

相關文章
相關標籤/搜索