cuda-convnet在Ubuntu12.04+CUDA5.5下的配置
deep learning近年來非常之火,尤其是在IMAGENET上的識別效果更是驚呆了小伙伴,其所用的Hinton的學生編寫的cuda-convet代碼早已公開,但是一直沒有時間去仔細研究,最近趁著清明小假期把這個試了下,首先是安裝CUDA5.5,需要安裝顯卡驅動,cuda toolkit and cuda sdk(samples),折騰半天搞好之后準備工作完畢,但是發現cuda-convnet使用的是CUDA4.0,其中使用了cutil(其中多處使用cutil_inline.h),而cuda5.0開始不再支持cutil:
Prior to CUDA 5.0, CUDA Sample projects referenced a utility lib rary with header and source files called cuti l. This has been removed with the CUDA Samples in CUDA 5.0, and re placed with header files found in CUDA Samples \ v5.0 \ common \ inc helper_cuda.h, helper_cuda_ gl.h, helper_cuda_drvapi.h, helper_functions.h, helper_image.h, helper_math.h, help er_string.h, and helper_timer.h .These files provide utility functions f or CUDA device initialization, CUDA error checking, string parsing, imag e file loading and saving, and timing functions. The CUDA Samples proj ects no longer have references and dependencies to cutil, and will now use these helper functions going forward.
導致編譯通不過。
?
解決方案:(參考:http://www.asiteof.me/archives/50和http://blog.csdn.net/xuanwu_yan/article/details/12784691,后者更為簡便)
在包含目錄下新建cutil_inline.h:
/* Dummy Includes for cutil_inline.h */ #include <helper_cuda.h> #define cutilCheckMsg(a) getLastCudaError(a) #define cutGetMaxGflopsDeviceId() gpuGetMaxGflopsDeviceId() #define MIN(a,b) (a) < (b) ? (a) : (b)利用cuda5.5SDK中helper_cuda.h的函數代替原來cutil函數即可
?
此外,makefile中需要包含cuda5.5 SDK目錄:
將build.sh中的CUDA_SDK_PATH改為相應的安裝目錄
export CUDA_SDK_PATH=/home/leon/NVIDIA_CUDA-5.5_Samples/common/inc
再將:INCLUDES?:=??-I$(PYTHON_INCLUDE_PATH)?-I$(NUMPY_INCLUDE_PATH)?-I./include?-I./include/common?-I./include/cudaconv2?-I./include/nvmatrix ?
改為:INCLUDES?:=??-I$(PYTHON_INCLUDE_PATH)?-I$(NUMPY_INCLUDE_PATH)?-I$(CUDA_SDK_PATH)?-I./include?-I./include/common?-I./include/cudaconv2?-I./include/nvmatrix ?
?
最后,使用helper_cuda.h后不再需要cutil的動態鏈接庫,所以直接把common-gcc-cuda-4.0.mk文件中的相應行注釋掉即可:
#LIB += -lcutil_$(LIB_ARCH)$(LIBSUFFIX) -lshrutil_$(LIB_ARCH)$(LIBSUFFIX)
?
sh build.sh
在/bin/linux/release目錄下生成_convnet.so文件即表示編譯成功!congratulations and enjoy your cuda-convnet/deep learning journey!
轉載于:https://www.cnblogs.com/cslxiao/p/3649844.html
總結
以上是生活随笔為你收集整理的cuda-convnet在Ubuntu12.04+CUDA5.5下的配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 3、PV、UIP、UV指的是什么
- 下一篇: win32汇编入门(一)