zoukankan      html  css  js  c++  java
  • 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!

  • 相关阅读:
    OpenCV笔记——cvFloodFill漫水填充算法
    C# 总结 随笔
    MYSQL存储过程 随笔
    MYSQL总结 随笔
    xPath 总结 随笔
    Javascript 总结 随笔
    linux中top查看cpu使用率超过100%
    页面优化小记1
    基于数据库的多语言解决方案
    基于消息队列的日志组件
  • 原文地址:https://www.cnblogs.com/cslxiao/p/3649844.html
Copyright © 2011-2022 走看看