利用SciTE的導(dǎo)出功能保持代碼語法著色效果
1297
2025-04-03
https://zhuanlan.zhihu.com/p/34942873
官方文檔:
1.?在windows下安裝tensorflow
2.?在windows下編譯tensorflow(cmake)
首先是系統(tǒng)配置:
OS:Windows Server 2012 R2(相當(dāng)于Windows 8)
GPU:NVIDIA Quadro K1200
然后是各種軟件版本:
git 2.14
Visual Studio 2015
CUDA 8.0.61
cuDNN 6.0
Anaconda3-4.2.0(此版本非最新版本,之所以使用是因?yàn)槠淠J(rèn)python版本為3.5.2)
cmake 3.9.1
swig 3.0.12
一、安裝CUDA
二、安裝tensorflow-gpu
pip install --ignore-installed --upgrade tensorflow-gpu
在CUDA_PATH后面添加bin和lib\x64路徑
將cudnn64_7改為cudnn64_6
如下:
#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)
1
2
3
4
5
6
7
8
三、編譯tensorflow-gpu
一些說明:使用pip或anaconda等方式安裝的預(yù)編譯好的tensorflow沒有AVX2指令集加速,通過手動(dòng)編譯可以更好的利用GPU。但是如果沒有AVX或者GPU的話,手動(dòng)編譯幾乎沒有優(yōu)勢(shì)。
官方只提供了Ubuntu和Mac OS X的編譯支持,在Windows下可以通過Bazel和CMake兩種方式進(jìn)行編譯,但只是 “highly experimental”,可能會(huì)遇到各種錯(cuò)誤。下面使用CMake來進(jìn)行編譯。
Cmake 3.5以上
Git
swig
swig安裝方法:
1.下載Swig for Windows:http://www.swig.org/download.html
2 解壓 .zip 文件到目錄,比如:D:\backupsoftware
3 添加環(huán)境變量到path, 比如: D:\backupsoftware\swigwin-2.0.9
4 添加環(huán)境變量?JAVA_INCLUDE 和?JAVA_BIN
JAVA_INCLUDE?: Set this to the directory containing jni.h
JAVA_BIN?: Set this to the bin directory containing javac.exe
Example using JDK1.3:
JAVA_INCLUDE: D:\jdk1.3\include
JAVA_BIN: D:\jdk1.3\bin
Note:D:\backupsoftware\swigwin-2.0.9 下面有 swig.exe 文件,注意這個(gè)目錄。
簡(jiǎn)單測(cè)試安裝是否成功:
打開Dos,在命令行執(zhí)行: swig --help, 顯示 Target Language Options即表明安裝成功。
Windows下的額外要求:
Visual Studio 2015
Python 3.5
Numpy 1.11.0 or later
命令行執(zhí)行:set PreferredToolArchitecture=x64
進(jìn)入目錄?C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\,運(yùn)行命令?vcvarsall amd64,從64位命令行編譯到64位的目標(biāo)平臺(tái)。執(zhí)行這一步可以避免編譯的時(shí)候出現(xiàn)內(nèi)存不足的錯(cuò)誤。
將CUDA dlls和cuDNN dll添加到環(huán)境變量:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
cudnn-8.0-windows7-x64-v7\cuda\bin
將Cmake和git添加到環(huán)境變量
CMake\bin
D:\temp> git clone https://github.com/tensorflow/tensorflow.git
D:\temp> cd tensorflow\tensorflow\contrib\cmake
D:\temp\tensorflow\tensorflow\contrib\cmake> mkdir build
D:\temp\tensorflow\tensorflow\contrib\cmake> cd build
D:\temp\tensorflow\tensorflow\contrib\cmake\build>
1
2
3
4
5
D:\...\build> cmake .. -A x64 -T host=x64 -DCMAKE_BUILD_TYPE=Release ^
-DSWIG_EXECUTABLE=D:/soft/swigwin-3.0.12/swig.exe ^
-DPYTHON_EXECUTABLE=D:/ProgramData/Miniconda3/python.exe ^
-DPYTHON_LIBRARIES=D:/ProgramData/Miniconda3/libs/python36.lib ^
-Dtensorflow_ENABLE_GPU=ON ^
-DCUDNN_HOME="D:\soft\python\cudnn7"
1
2
3
4
5
6
7
1
2
1
1
2
如果有NVIDIA顯卡,且安裝好了cuDNN,那么可以添加以下參數(shù):
More? -Dtensorflow_ENABLE_GPU=ON ^
More? -DCUDNN_HOME="D:\...\cudnn"
1
2
3
使用以下命令產(chǎn)生.whl文件
D:\...\build> MSBuild /p:Configuration=Release tf_python_build_pip_package.vcxproj
1
還有一種命令: MSBuild /p:Configuration=Release /p:Platform=x64 tf_python_build_pip_package.vcxproj
編譯成功后,whl路徑;
D:\soft\tensorflow-r1.6\tensorflow\contrib\cmake\build\tf_python\dist
遇到的問題:
點(diǎn)擊生成解決方案,編譯的時(shí)間很長(zhǎng),我的筆記本電腦編譯一次大概3到4個(gè)小時(shí),編譯到最后一般都會(huì)報(bào)錯(cuò)
fatal error C1060: compiler is out of heap space?沒關(guān)系,等待整個(gè)工程全部編譯完成(據(jù)說內(nèi)存特別大的電腦不會(huì)報(bào))
error C2001: newline in constant
打開對(duì)應(yīng)的文件發(fā)現(xiàn)出現(xiàn)了亂碼,google之后發(fā)現(xiàn)可以通過修改locale為 英語(美國) 來解決。
編譯過程中下載失敗或者 git clone緩慢
使用命令?nslookup?查找失效ip(github.global.ssl.fastly.net,storage.googleapis.com等),修改host文件。完了之后?ipconfig /flushdns。當(dāng)然也可以嘗試手動(dòng)下載到對(duì)應(yīng)的目錄。
我這里的報(bào)錯(cuò):
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cinttypes(20): error C2039: “imaxdiv_t”: 不是“`global namespace'”的成員 [D:\soft\python\tensorflow-master\tensorflow
\contrib\cmake\build\grpc\src\grpc\grpc_unsecure.vcxproj] [D:\soft\python\tensorflow-master\tensorflow\contrib\cmake\build\grpc.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cinttypes(20): error C2873: “imaxdiv_t”: 符號(hào)不能用在 using 聲明中 [D:\soft\python\tensorflow-master\tensorflow\contrib\
cmake\build\grpc\src\grpc\grpc_unsecure.vcxproj] [D:\soft\python\tensorflow-master\tensorflow\contrib\cmake\build\grpc.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cinttypes(22): error C2039: “imaxabs”: 不是“`global namespace'”的成員 [D:\soft\python\tensorflow-master\tensorflow\c
ontrib\cmake\build\grpc\src\grpc\grpc_unsecure.vcxproj] [D:\soft\python\tensorflow-master\tensorflow\contrib\cmake\build\grpc.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cinttypes(22): error C2873: “imaxabs”: 符號(hào)不能用在 using 聲明中 [D:\soft\python\tensorflow-master\tensorflow\contrib\cm
ake\build\grpc\src\grpc\grpc_unsecure.vcxproj] [D:\soft\python\tensorflow-master\tensorflow\contrib\cmake\build\grpc.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cinttypes(22): error C2039: “imaxdiv”: 不是“`global namespace'”的成員
服務(wù)器上jdk_include添加了,報(bào)錯(cuò):
D:\soft\tensorflow-master\tensorflow\c\python_api.cc(19): fatal error C1083: 無法打開包括文件: “tensorflow/python/framework/c
pp_shape_inference.pb.h”: No such file or directory [D:\soft\tensorflow-master\tensorflow\contrib\cmake\build\tf_c_pyth
on_api.vcxproj]
AI GPU加速云服務(wù)器 TensorFlow Windows
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。