手机版
你好,游客 登录 注册
背景:
阅读新闻

Ubuntu 14.04配置cuda-convnet

[日期:2014-10-02] 来源:Linux社区  作者:stdcoutzyx [字体:大 中 小]

3. Cuda-convnet2配置

顾名思义,这是cuda-convnet的2.0版本,支持多GPU运行。

3.1. 源码下载

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

3.2. 必要的库

  1. 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直接如此。

  1. # CUDA toolkit installation directory. 
  2. export CUDA_INSTALL_PATH=/usr/local/cuda 
  3.    
  4. # Python include directory. This should contain the file Python.h, among others. 
  5. export PYTHON_INCLUDE_PATH=/usr/include/python2.7 
  6.    
  7. # Numpy include directory. This should contain the file arrayobject.h, among others. 
  8. export NUMPY_INCLUDE_PATH=/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ 
  9.    
  10. # ATLAS library directory. This should contain the file libcblas.so, among others. 
  11. export ATLAS_LIB_PATH=/usr/lib/atlas-base 
  12.    
  13. # You don't have to change these: 
  14. export LD_LIBRARY_PATH=$CUDA_INSTALL_PATH/lib64:$LD_LIBRARY_PATH 
  15. export CUDA_SDK_PATH=$CUDA_INSTALL_PATH/samples 
  16. export PATH=$PATH:$CUDA_INSTALL_PATH/bin 

如果是在Ubuntu下的话,这样就直接已经基本把路径都配置对了。

3.4. 链接错误

但是直接编译的话还是会遇到错误,如下所示:

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

主要是因为atlas库中没有libatlas.so和libctlas.so。查看atlas的目录发现结构如此:

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

添加两个软链接,执行命令:

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

目录结构变为如此:

  1. /usr/lib/atlas-base$ ls -l 
  2. 总用量 4292 
  3. drwxr-xr-x 2 root root    4096  9月 22 11:41 atlas 
  4. lrwxrwxrwx 1 root root      15 10月  1 22:35 libatlas.so -> libatlas.so.3.0 
  5. lrwxrwxrwx 1 root root      15  2月  4  2014 libatlas.so.3 -> libatlas.so.3.0 
  6. -rw-r--r-- 1 root root 3746968  2月  4  2014 libatlas.so.3.0 
  7. lrwxrwxrwx 1 root root      15 10月  1 22:36 libcblas.so -> libcblas.so.3.0 
  8. lrwxrwxrwx 1 root root      15  2月  4  2014 libcblas.so.3 -> libcblas.so.3.0 
  9. -rw-r--r-- 1 root root  135376  2月  4  2014 libcblas.so.3.0 
  10. lrwxrwxrwx 1 root root      17  2月  4  2014 libf77blas.so.3 -> libf77blas.so.3.0 
  11. -rw-r--r-- 1 root root  131000  2月  4  2014 libf77blas.so.3.0 
  12. lrwxrwxrwx 1 root root      22  2月  4  2014 liblapack_atlas.so.3 -> liblapack_atlas.so.3.0 
  13. -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

更多Ubuntu相关信息见Ubuntu 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=2

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-10/107500.htm 

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款