欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

Ubuntu14.04配置cuda-convnet

系統 2406 0

轉載請注明:http://blog.csdn.net/stdcoutzyx/article/details/39722999

在上一個鏈接中,我配置了 cuda ,有強大的 GPU ,自然不能暴殄天物,讓資源白白空暇著,所以配置一下卷積神經網絡跑一下程序嘍。至于卷積神經網絡的原理,容后再寫。打算先寫庫的使用方法,再寫原理,以行動帶動對理論的追求。

話不多說,步入正題。

1.?預說明

關于 cuda-convnet ,起源于一篇經典論文 ①,論文中針對 ILSVRC-2010 的數據進行實驗,然后發布了事實上驗使用的代碼,鏈接為 ②。可是,事實往往跟論文是有差距的,鏈接②中的代碼根本不能重現論文中的結果。在下不才,在使用這個鏈接的庫非常久之后才發現的,認為非常坑,希望后來者慎之。

之所以說它坑,首先,論文中提到特性中, multi-GPU dropout 就沒有實現,并且也沒有給出論文中 8 層卷積神經網絡的配置文件。總之不能直接拿來用,須要自己探索。

盡管如此,但有總比沒有好,畢竟這個庫實現的卷積神經網絡封裝的非常好,論文中的大神的貢獻非我等小菜所能企及的。給大神點 32 個贊。

本文僅僅對 cuda-convnet cuda-convnet2 的配置進行說明,論文中的作者還發布了其它版本號的庫,尚未用到,故且按下不提。

2.?Cuda-convnet 配置

2.1.?源代碼下載

參考鏈接②,先將源代碼下載下來。

      svn checkout http://cuda-convnet.googlecode.com/svn/trunk/ cuda-convnet-read-only
    

取出的版本號是 562

2.2.?安裝必要的庫

然后,安裝必須的庫,我使用的是 ubuntu 系統。所以命令為

      sudo apt-get install python-dev python-numpy python-magic python-matplotlib libatlas-base-dev
    

當然,還要確認你安裝了 cuda ,我安裝的是 cuda6.5 ,在 /usr/local/ 文件夾下,例如以下所看到的:

      $ ls /usr/local
bin  cuda  cuda-6.5  etc  games  include  lib  man  sbin  share  src
    

2.3.?更改 build.sh

進入到剛才下載的 cuda-convnet-read-only 文件夾,更改 build.sh 文件里的配置路徑。例如以下所看到的:

      # CUDA toolkit installation directory.
export CUDA_INSTALL_PATH=/usr/local/cuda
 
# CUDA SDK installation directory.
export CUDA_SDK_PATH=/usr/local/cuda-6.5/samples/common/inc
 
# Python include directory. This should contain the file Python.h, among others.
export PYTHON_INCLUDE_PATH=/usr/include/python2.7
 
# Numpy include directory. This should contain the file arrayobject.h, among others.
export NUMPY_INCLUDE_PATH=/usr/lib/python2.7/dist-packages/numpy/core/include/numpy
 
# ATLAS library directory. This should contain the file libcblas.so, among others.
export ATLAS_LIB_PATH=/usr/lib/atlas-base
 
make $*
    


依照官網的教程,配置完 build.sh 后就能夠進行編譯了。可是會錯誤發生,還須要改例如以下幾個地方才干夠。

2.4.?頭文件加入

直接編譯會發生找不到 cutil_inline.h 頭文件的錯誤。分析原因可能是原來有這個頭文件,后來這個頭文件的功能被實現到其它頭文件里去了。

include 子目錄下田間 cutil_inline.h 文件,并輸入內容。

      #include "helper_cuda.h"
#define cutilCheckMsg(a) getLastCudaError(a)
#define cutGetMaxGflopsDeviceId() gpuGetMaxGflopsDeviceId()
#define MIN(a,b) (a) < (b) ? (a) : (b)
    

2.5.?MakeFile 文件更改

MakeFile 3 行,原文例如以下:

      INCLUDES :=  -I$(PYTHON_INCLUDE_PATH) -I$(NUMPY_INCLUDE_PATH) -I./include -I./include/common -I./include/cudaconv2 -I./include/nvmatrix
    

加入 cuda 的路徑后例如以下:

      INCLUDES :=  -I$(PYTHON_INCLUDE_PATH) -I$(NUMPY_INCLUDE_PATH) -I$(CUDA_SDK_PATH) -I./include -I./include/common -I./include/cudaconv2 -I./include/nvmatrix
    

保存之。

2.6.?最后的庫鏈接錯誤

做完上述修改后,能夠編譯了,但到最后會發生一個庫鏈接的錯誤,不用管,直接將那個庫凝視掉。

common-gcc-cuda-4.0.mk 文件的 332 行。直接用 # 號凝視。

      # LIB += -lcutil_$(LIB_ARCH) $(LIBSUFFIX) -lshrutil_$(LIB_ARCH) $(LIBSUFFIX)
    

至此,就能夠完畢 cuda-convnet 的編譯了。

3.?Cuda-convnet2 配置

顧名思義,這是 cuda-convnet 2.0 版本號,支持多 GPU 執行。

3.1.?源代碼下載

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

3.2.?必要的庫

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

3.3.?配置

我僅僅能說,這個版本號的比上個版本號人性化多了,這個版本號的 build.sh 直接如此。

      # CUDA toolkit installation directory.
export CUDA_INSTALL_PATH=/usr/local/cuda
 
# Python include directory. This should contain the file Python.h, among others.
export PYTHON_INCLUDE_PATH=/usr/include/python2.7
 
# Numpy include directory. This should contain the file arrayobject.h, among others.
export NUMPY_INCLUDE_PATH=/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/
 
# ATLAS library directory. This should contain the file libcblas.so, among others.
export ATLAS_LIB_PATH=/usr/lib/atlas-base
 
# You don't have to change these:
export LD_LIBRARY_PATH=$CUDA_INSTALL_PATH/lib64:$LD_LIBRARY_PATH
export CUDA_SDK_PATH=$CUDA_INSTALL_PATH/samples
export PATH=$PATH:$CUDA_INSTALL_PATH/bin
    

假設是在 ubuntu 下的話,這樣就直接已經基本把路徑都配置對了。

3.4.?鏈接錯誤

可是直接編譯的話還是會遇到錯誤,例如以下所看到的:

      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
/usr/bin/ld: cannot find -latlas
/usr/bin/ld: cannot find -lcblas
collect2: error: ld returned 1 exit status
    

主要是由于 atlas 庫中沒有 libatlas.so libctlas.so 。查看 atlas 的文件夾發現結構如此:

      :/usr/lib/atlas-base$ ls -l
總用量 4292
drwxr-xr-x 2 root root    4096  9月 22 11:41 atlas
lrwxrwxrwx 1 root root      15  2月  4  2014 libatlas.so.3 -> libatlas.so.3.0
-rw-r--r-- 1 root root 3746968  2月  4  2014 libatlas.so.3.0
lrwxrwxrwx 1 root root      15  2月  4  2014 libcblas.so.3 -> libcblas.so.3.0
-rw-r--r-- 1 root root  135376  2月  4  2014 libcblas.so.3.0
lrwxrwxrwx 1 root root      17  2月  4  2014 libf77blas.so.3 -> libf77blas.so.3.0
-rw-r--r-- 1 root root  131000  2月  4  2014 libf77blas.so.3.0
lrwxrwxrwx 1 root root      22  2月  4  2014 liblapack_atlas.so.3 -> liblapack_atlas.so.3.0
-rw-r--r-- 1 root root  369472  2月  4  2014 liblapack_atlas.so.3.0
    

加入兩個軟鏈接,運行命令:

      sudo ln -s libatlas.so.3.0 libatlas.so
sudo ln -s libcblas.so.3.0 libcblas.so
    

文件夾結構變為如此:

      /usr/lib/atlas-base$ ls -l
總用量 4292
drwxr-xr-x 2 root root    4096  9月 22 11:41 atlas
lrwxrwxrwx 1 root root      15 10月  1 22:35 libatlas.so -> libatlas.so.3.0
lrwxrwxrwx 1 root root      15  2月  4  2014 libatlas.so.3 -> libatlas.so.3.0
-rw-r--r-- 1 root root 3746968  2月  4  2014 libatlas.so.3.0
lrwxrwxrwx 1 root root      15 10月  1 22:36 libcblas.so -> libcblas.so.3.0
lrwxrwxrwx 1 root root      15  2月  4  2014 libcblas.so.3 -> libcblas.so.3.0
-rw-r--r-- 1 root root  135376  2月  4  2014 libcblas.so.3.0
lrwxrwxrwx 1 root root      17  2月  4  2014 libf77blas.so.3 -> libf77blas.so.3.0
-rw-r--r-- 1 root root  131000  2月  4  2014 libf77blas.so.3.0
lrwxrwxrwx 1 root root      22  2月  4  2014 liblapack_atlas.so.3 -> liblapack_atlas.so.3.0
-rw-r--r-- 1 root root  369472  2月  4  2014 liblapack_atlas.so.3.0
    

然后就能夠正常編譯了。

參考文獻

① ImageNet?Classification?with?Deep?Convolutional?Neural?Networks

②  https://code.google.com/p/cuda-convnet

③  https://code.google.com/p/cuda-convnet2

Ubuntu14.04配置cuda-convnet


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: mmmwww| 欧美精品影视 | 成人影院欧美大片免费看 | 久久久久国产精品 | 久久夜色精品国产亚洲 | 91成人国产网站在线观看 | 69久久国产精品热88人妻 | 日日摸天天碰中文字幕 | 亚洲日本中文字幕在线2022 | 一区二区三区中文字幕 | 性生潮久久久不久久久久 | 99动漫| 午夜视频在线网站 | 亚洲成人小视频 | 久久88 | 青青久视频 | 日本成人在线网站 | 天天摸天天操天天干 | 99热在线播放 | 久久久九九精品国产毛片A片 | 三a级片 | 国产一区二区三区日韩欧美 | 色久五月| 久久这里只有精品23 | 国产精品欧美日韩 | 精品一区二区三区水蜜桃 | 天天色影 | 中文字幕一区二区三区四区五区 | 免费看在线偷拍视频 | 六月色播| 久久人人爱 | 亚洲欧美一级久久精品 | 欧美另类videosbestsex久久 | 国产精品国产精品 | 精品欧美高清一区二区免费 | 欧美精品一区二区三区久久 | 欧美日韩精品一区二区三区在线观看 | 青青草视频破解版 | 天天干天天添 | 一区二区三区免费在线观看 | 久久久久亚洲视频 |