cuda-convnet2使用

环境: Ubuntu 12.04,  cuda-convnet2,  CUDA 6

安装步骤:

1. 预安装需求库

sudo apt-get install python-dev python-numpy python-scipy python-magic python-matplotlib libatlas-base-dev libjpeg-dev libopencv-dev git

2.  安装CUDA 6.0
从http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1204/x86_64/cuda-repo-ubuntu1204_6.5-14_amd64.deb下载  cuda-repo-ubuntu1204_6.5-14_amd64.deb
$wget  http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1204/x86_64/cuda-repo-ubuntu1204_6.5-14_amd64.deb
 $ sudo dpkg -i cuda-repo-ubuntu1204_6.0-37_amd64.deb 
 $ sudo apt-get update
 $ sudo apt-get install cuda

3. 配置CUDA环境变量

vi ~/.bashrc

export CUDA_HOME=/usr/local/cuda-6.0 
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64 
 
PATH=${CUDA_HOME}/bin:${PATH} 
export PATH
 
4. 下载cuda-convnet2源码

git clone https://code.google.com/p/cuda-convnet2/

5. 编译源码

jerry@hq:/u01/cuda-convnet2$ sh build.sh
mkdir -p ./bin//src
g++  -O3 -c -fPIC   -DNUMPY_INTERFACE -I./include -I/usr/include/python2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ src/matrix.cpp -o ./bin//src/matrix.o
In file included from /usr/include/python2.7/Python.h:8:0,
                 from src/../include/matrix.h:22,
                 from src/matrix.cpp:17:
/usr/include/python2.7/pyconfig.h:1161:0: warning: "_POSIX_C_SOURCE" redefined [enabled by default]
 #define _POSIX_C_SOURCE 200112L
 ^
In file included from /usr/include/stdlib.h:25:0,
                 from src/../include/matrix_funcs.h:20,
                 from src/../include/matrix.h:20,
                 from src/matrix.cpp:17:
/usr/include/features.h:164:0: note: this is the location of the previous definition
 # define _POSIX_C_SOURCE 200809L
 ^
In file included from /usr/include/python2.7/Python.h:8:0,
                 from src/../include/matrix.h:22,
                 from src/matrix.cpp:17:
/usr/include/python2.7/pyconfig.h:1183:0: warning: "_XOPEN_SOURCE" redefined [enabled by default]
 #define _XOPEN_SOURCE 600
 ^
In file included from /usr/include/stdlib.h:25:0,
                 from src/../include/matrix_funcs.h:20,
                 from src/../include/matrix.h:20,
                 from src/matrix.cpp:17:
/usr/include/features.h:166:0: note: this is the location of the previous definition
 # define _XOPEN_SOURCE 700
 ^
cd ./bin/ && g++  -O3   -DNUMPY_INTERFACE -shared -Wl,-no-undefined -o libutilpy.so src/matrix.o -L/usr/lib/atlas-base -latlas -lcblas -lpython2.7
ln -sf ./bin//libutilpy.so .
mkdir -p ./bin/release
mkdir -p ./obj/release/src
mkdir -p ./bin/release
mkdir -p ./obj/release/src
mkdir -p ./bin/release
mkdir -p ./obj/release/src
mkdir -p ./bin//src
g++  -O3 -c -fPIC   -I./include -I/usr/include/python2.7  src/pyext.cpp -o ./bin//src/pyext.o
In file included from /usr/include/python2.7/Python.h:8:0,
                 from src/../include/pyext.h:23,
                 from src/pyext.cpp:17:
/usr/include/python2.7/pyconfig.h:1161:0: warning: "_POSIX_C_SOURCE" redefined [enabled by default]
 #define _POSIX_C_SOURCE 200112L
 ^
In file included from /usr/include/stdio.h:28:0,
                 from src/../include/pyext.h:20,
                 from src/pyext.cpp:17:
/usr/include/features.h:164:0: note: this is the location of the previous definition
 # define _POSIX_C_SOURCE 200809L
 ^
In file included from /usr/include/python2.7/Python.h:8:0,
                 from src/../include/pyext.h:23,
                 from src/pyext.cpp:17:
/usr/include/python2.7/pyconfig.h:1183:0: warning: "_XOPEN_SOURCE" redefined [enabled by default]
 #define _XOPEN_SOURCE 600
 ^
In file included from /usr/include/stdio.h:28:0,
                 from src/../include/pyext.h:20,
                 from src/pyext.cpp:17:
/usr/include/features.h:166:0: note: this is the location of the previous definition
 # define _XOPEN_SOURCE 700
 ^
cd ./bin/ && g++  -O3   -shared -Wl,-no-undefined -o _MakeDataPyExt.so src/pyext.o -L/usr/local/cuda/lib64 `pkg-config --libs python` `pkg-config --libs opencv` -lpthread
ln -sf ./bin//_MakeDataPyExt.so .


6.  运行脚本
jerry@hq:/u01/cuda-convnet2$ python convnet.py --data-path=/u01/lisa/data/cifar10/cifar-10-batches-py --save-path=/u01/jerry/tmp --test-range=5 --train-range=1-4 --layer-def=./layers/layers-cifar10-11pct.cfg --layer-params=./layers/layer-params-cifar10-11pct.cfg --data-provider=cifar-cropped --test-freq=13 --epochs=100                
Option --gpu (GPU override) not supplied
convnet.py usage:
    Option                             Description                                                              Default
    [--check-grads <0/1>           ] - Check gradients and quit?                                                [0]
    [--color-noise         ] - Add PCA noise to color channels with given scale                         [0]
    [--conserve-mem <0/1>          ] - Conserve GPU memory (slower)?                                            [0]
    [--conv-to-local  ] - Convert given conv layers to unshared local                              []
    [--epochs                ] - Number of epochs                                                         [50000]
    [--feature-path       ] - Write test data features to this path (to be used with --write-features) []
    [--force-save <0/1>            ] - Force save before quitting                                               [0]
    [--inner-size            ] - Cropped DP: crop size (0 = don't crop)                                   [0]
    [--layer-path         ] - Layer file path prefix                                                   []
    [--load-file          ] - Load file                                                                []
    [--logreg-name        ] - Logreg cost layer name (for --test-out)                                  []
    [--mini                  ] - Minibatch size                                                           [128]
    [--multiview-test <0/1>        ] - Cropped DP: test on multiple patches?                                    [0]
    [--scalar-mean         ] - Subtract this scalar from image (-1 = don't)                             [-1]
    [--test-freq             ] - Testing frequency                                                        [57]
    [--test-one <0/1>              ] - Test on one batch at a time?                                             [1]
    [--test-only <0/1>             ] - Test and quit?                                                           [0]
    [--test-out           ] - Output test case predictions to given path                               []
    [--unshare-weights ] - Unshare weight matrices in given layers                                  []
    [--write-features     ] - Write test data features from given layer                                []
     --data-path            - Data path
     --data-provider        - Data provider
     --gpu                 - GPU override
     --layer-def            - Layer definition file
     --layer-params         - Layer parameter file
     --save-file            - Save file override
     --save-path            - Save path
     --test-range        - Data batch range: testing
     --train-range       - Data batch range: training



由于ubuntu是在windows里的虚拟机,无法使用本机或外置的gpu显卡, 故无法运行程序。 有点遗憾



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16582684/viewspace-1254584/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/16582684/viewspace-1254584/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值