標籤:style blog code http tar color
編譯環境:
windows8.1
Anaconda python2.7
Visual studio 2012
CUDA6.0
Pthread for windows
Intel Math Kernel Library
cuda-convnet 原始檔案:https://github.com/dnouri/cuda-convnet/
其中用到的一些庫:
PThread 下載連結:
ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zipIntel® Math Kernel Library 下載連結:(下載windows版本)https://software.intel.com/en-us/intel-math-kernel-library-evaluation-optionscuda-convnet 工程檔案下載連結:http://code.google.com/p/cuda-convnet/downloads/detail?name=cuda-convnet-vs-proj.zip其他一些有用的工具:(下載x64的版本,調試的時候可能用到)http://www.dependencywalker.com/ 因為cuda-convnet需要python27,所以必須下載python27的庫安裝上. 我用的是Anaconda內建的python庫. 第一步:把下載下來的cuda工程檔案解壓至trunk目錄下,然後用記事本開啟pyconvnet.vcxproj檔案然後把版本號碼修改為正確的版本號碼,我的是把cuda4.0 修改為cuda6.0 第二步:編譯時間會遇到以下問題,那是標頭檔沒包含對的緣故,不用擔心C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\CUDA 6.0.targets(597,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --use-local-env --cl-version 2012 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin" -I./ -I../../../common/inc -I../../../../shared/inc -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -I./ -I../../common/inc -I../../../shared/inc -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MTd " -o Win32/Debug/convnet.cu.obj "E:\synchronize folder\Koder Quelle\deep learning\cuda-convnet\trunk\src\convnet.cu"" exited with code 2.針對這些錯誤只要設定好相應的依賴庫就可以了. 第三步:最後編譯產生的是dll,尾碼名為pyd, 這樣方便python調用. 第四步:從下面的地址下載cifar-10圖片資料http://www.cs.toronto.edu/~kriz/cifar.html 第五步:在VS環境中設定環境變數 第六步:在命令列中輸入如下命令:python convnet.py --data-path=./storage2/tiny/cifar-10-batches-py-colmajor/ --save-path=./storage2/tmp --test-range=6 --train-range=1-5 --layer-def=./example-layers/layers-19pct.cfg --layer-params=./example-layers/layer-params-19pct.cfg --data-provider=cifar --test-freq=13 --epoch=200 訓練的時候發現一個比較坑的問題就是這兩個錯誤:1.raise UnpickleError("Path ‘%s‘ does not exist." % filename)util.UnpickleError: Path ‘D:/cuda-convnet/storage2/tiny/cifar-10-batches-py-colmajor/data_batch_6‘ does not exist.2.self.data_mean = self.batch_meta[‘data_mean‘]KeyError: ‘data_mean‘原因是batches_meta檔案格式不對,這個必須去下載對應的cifar-10的資料,而且帶有合乎要求格式的檔案,下面給上連結:http://www.cs.toronto.edu/~kriz/cifar-10-py-colmajor.tar.gz 即使找到合適的資料,還可能出現以下的錯誤:self.libmodel = __import__(lib_name)ImportError: No module named convnet_解決方案就是在convnet.py的46行把‘convnet_‘庫改成對應的‘pyconvnet‘ 解決了以上的問題以後差不多應該能夠順利的運行程式了. 編譯時間遇到的錯誤及解決方案: fatal error C1083: Cannot open include file: ‘cblas.h‘: No such file or directory解決方案:屬性頁面/C++/Preprocessor/Preprocessor definitions/加入USE_MKL; neuron.cuh(104): error : identifier "PyObject" is undefined解決方案:屬性頁面/C++/Preprocessor/Preprocessor definitions/加入NUMPY_INTERFACE; 編譯的時候提示找不到pthread.h檔案:解決方案:在trunk中加入下載好的pthread檔案夾,並正確的包含標頭檔和庫檔案 編譯的時候報error : identifier "pthread_mutex_t" is undefined錯誤:解決方案:在nvmatrix.cuh檔案裡加上<pthread.h> LINK : fatal error LNK1104: cannot open file ‘cutil64D.lib‘解決方案:去掉cutil64D.lib LINK : fatal error LNK1104: cannot open file ‘shrUtils64D.lib‘解決方案:去掉shrUtils64D.lib