TensorFlow時碰到的問題(GPU)

測試環境:GTX965M,python3.6.x(GPU安裝TensorFlow),win10
下面列出了我安裝TensorFlow時碰到的問題


1.在安裝時候易出現decode錯誤是由於
解決方法:
打開 c:\program files\python36\lib\site-packages\pip\compat\__init__.py 約75行 
return s.decode('utf_8') 改爲return s.decode('cp936')
原因: 
編碼問題,雖然py3統一用utf-8了。但win下的終端顯示用的還是gbk編碼。
不同版本可能報錯地方可能不一樣。


2.ImportError: Could not find 'cudart64_80.dll'. TensorFlow requires that this DLL be installed in a directory that is nam
ed in your %PATH% environment variable. Download and install CUDA 8.0 from this URL: https://developer.nvidia.com/cuda-t
oolkit
原因CUDA最新版是9.0下載時下載了9.0版本
解決辦法:下載8.0版本(默認傳統安裝)
http://blog.csdn.net/akon_wang_hkbu/article/details/78478513


3.在導入TensorFlow時報錯找不到dll文件則是在環境變量沒配置好
解決辦法:在win10中的高級系統設置中修改系統變量
網上有兩種說法一個是加在Path變量上還有CUDA_PATH上(我兩個都加上了)
如果你安裝是默認的話應該是以下三個路徑:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64


4.cudnn64_6.dll問題
關於導入TensorFlow找不到cudnn64_6.dll,其實下載的的是cudnn64_7.dll(可能是比較新),用管理員權限修改過來就行了。
目錄是在:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin


5.cuDnn庫下載
https://developer.nvidia.com/cudnn
下載這個安裝包需要註冊並且填一堆問卷,下下來以後把相關包不用安裝,直接拷到cuda路徑對應的C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0文件夾下面就行(不是替換)


附上:
Anaconda安裝坑稍微少一些,據說如果會配置會比直接上手快得多
參考:http://blog.csdn.net/sb19931201/article/details/53648615
還有看了下網上教程可能會linux/mac的用命令行配置速度更快
win10坑不少。


官方測試(測試前先導入TensorFlow......)
The TensorFlow implement 
ation translates the graph definition into executable operations distributed across available compute resources, such as the CPU or one of your computer’s GPU cards. In general you do not have to specify CPUs or GPUs explicitly. TensorFlow uses your first GPU, if you have one, for as many operations as possible.


#Creates a graph.
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
#Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
#Runs the op.
print sess.run(c)
輸出:


Device mapping:
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: Tesla K40c, pci bus
id: 0000:05:00.0
b: /job:localhost/replica:0/task:0/gpu:0
a: /job:localhost/replica:0/task:0/gpu:0
MatMul: /job:localhost/replica:0/task:0/gpu:0
[[ 22.  28.]
 [ 49.  64.]]


通過上述官方測試算是成功了,可能屏幕會黑一下(顯卡性能問題)。
 [ 49.  64.]]
附上一些GitHub的源碼測試:
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章