现在cuda8.0支持的gccgcc5.4吗

2598人阅读
编译sample里面的例子,出现错误:unsupported GNU version! gcc 4.7 and up are not supported!
坑爹阿,gcc又没法降版本,要卸载的话机器上一大堆程序都得全卸载了,貌似唯一的方法就是再装一个gcc4.6
这样只能从源码编译
按照这里装好第二个gcc后&&
可以使用 nvcc --compiler-bindir 来指定另外的编译器目录
sudo ln -s /usr/local/gcc46/bin/gcc46 /usr/local/cuda/bin/gcc
sudo ln -s /usr/local/gcc46/bin/g++46 /usr/local/cuda/bin/g++
当然,上面的gcc46是我安装gcc-4.6的目录
进行链接后,问题也就解决了。
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:388711次
积分:4693
积分:4693
排名:第6051名
原创:118篇
转载:18篇
评论:68条
(1)(2)(1)(1)(4)(4)(2)(2)(2)(3)(7)(2)(2)(3)(5)(1)(1)(10)(1)(3)(2)(2)(2)(7)(21)(17)(5)(9)(4)(1)(2)(5)(2)深度学习(四十一)cuda8.0+ubuntu16.04+theano、caffe、tensorflow环境搭建 - ITkeyowrd
深度学习(四十一)cuda8.0+ubuntu16.04+theano、caffe、tensorflow环境搭建
cuda8.0+ubuntu16.04+theano、caffe、tensorflow环境搭建
目前自己撘过深度学习各种库、各种环境,已经搭建了n多台电脑,发现每台电脑配置安装方法各不相同,总会出现各不相同的错误,真是心塞。笔记本和台式机有差别,台式机之间的安装方法又各不相同,不同的系统版本环境、平台又各有差异。比如昨天搞的一台电脑,可能因为显卡比较新,然而ubuntu14.04、ubuntu15.04都比较旧,连安装系统都装不上,一开始在14.04上重装了n多次系统,还以为是自己电脑的问题。最后在ubuntu16.04竟然非常顺利完成了安装;然而16.04的版本,只有cuda8.0才支持,在这台破电脑上,又折腾了我快一天的时间。
显卡:GTX960
环境:ubuntu16.04、cuda8.0
下面是我的安装之路,总的来说theano、keras、tensorflow都比较容易安装;最难安装的是caffe,因为caffe调用的第三方库比较杂、比较多。
一、安装cuda8.0
1、输入命令:
sudo vim /etc/modprobe.d/blacklist.conf在文件最后面,添加:
blacklist nouveau
sudo reboot
sudo apt-get remove --purge nvidia*
重启,然后进入终端:
sudo service lightdm stop
chmod +x cuda*.run
sudo ./cuda*.run
2、安装cuda的过程中,一直跳出错误:
If you're sure that X is not running, but are getting this error, please delete any X lock files in /tmp.
那么我们可以直接删除X-lock文件,具体命令为:
sudo rm /tmp/.X0-lock
3、ubuntu的gcc编译器是5.4.0,然而cuda8.0不支持5.0以上的编译器,因此需要降级,把编译器版本降到4.9:
sudo apt-get install g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
等待安装完成
4、配置环境变量:
sudo vim /etc/profile 在文件末尾添加:
PATH=/usr/local/cuda/bin:$PATH
export PATH
保存退出。输入命令:
source /etc/profile
使其生效。
输入命令:
sudo /etc/ld.so.conf.d/cuda.conf
添加内容:
/usr/local/cuda/lib64
5、验证测试
测试cuda是否安装成功:
cd /usr/local/cuda/samples
编译例子:
sudo make all -j8 运行编译可执行结果文件:
./deviceQuery
二、安装theano
1、直接输入命令:
sudo pip install theano
2、配置参数文件:.theanorc
floatX=float32
device=gpu
base_compiledir=~/external/.theano/
allow_gc=False
warn_float64=warn
[mode]=FAST_RUN
fastmath=True
root=/usr/local/cuda
3、运行测试例子:
from theano import function, config, shared, sandbox
import theano.tensor as T
import numpy
import time
vlen = 10 * 30 * 768
# 10 x #cores x # threads per core
iters = 1000
rng = numpy.random.RandomState(22)
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
f = function([], T.exp(x))
print(f.maker.fgraph.toposort())
t0 = time.time()
for i in range(iters):
t1 = time.time()
print(&Looping %d times took %f seconds& % (iters, t1 - t0))
print(&Result is %s& % (r,))
if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]):
print('Used the cpu')
print('Used the gpu')
可以看到结果:
/usr/bin/python2.7 /home/hjimce/PycharmProjects/untitled/.idea/temp.py
Using gpu device 0: GeForce GTX 960 (CNMeM is disabled, cuDNN not available)
[GpuElemwise{exp,no_inplace}(&CudaNdarrayType(float32, vector)&), HostFromGpu(GpuElemwise{exp,no_inplace}.0)]
Looping 1000 times took 0.302778 seconds
Result is [ 1... ...,
Used the gpu
三、caffe环境搭建
1、切换编译器:
sudo update-alternatives --config g++ 选择g++ 5.0以上的对应编号
sudo update-alternatives --config gcc 根据编号选择gcc编译器5.0以上的版本。
2、hd5相关问题:遇到hd5等相关找不到的文件错误。
输入命令:
cd /usr/lib/x86_64-linux-gnu
sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.so
sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so
3、caffe编译
从github上下载caffe,解压打开makefile.config对其进行修改,makefile.config修改内容内容如下:
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib改为:
INCLUDE_DIRS :=
$(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial
4、cuda8.0编译器问题
打开/usr/local/cuda/include/host_config.h
error -- unsupported GNU version! gcc versions later than 5.3 are not supported!
结果如下:
#if __GNUC__ & 5 || (__GNUC__ == 5 && __GNUC_MINOR__ & 3)
//#error -- unsupported GNU version! gcc versions later than 5.3 are not supported!
#endif /* __GNUC__ & 5 || (__GNUC__ == 5 && __GNUC_MINOR__ & 1) */
5、遇到prototuf等编译问题:
build_release/lib/libcaffe.so: undefined reference to 'google::protobuf::io::CodedOutputStream::WriteVarint64ToArray(unsigned long long, unsigned char*)'主要是因为我们直接采用命令apt-get install 安装prototuf是比较老旧的版本,而ubuntu16.04比较新,所以我们需要卸载 prototuf,然后自己在自己的电脑上编译安装。
(1)于是先卸载原有版本:
sudo apt-get autoremove libprotobuf-dev protobuf-compiler (2)从github下载protobuf
(3)打开protobuf文件目录进行编译安装,具体过程如下
编译过程过下:
A、输入命令:
sh auto*.sh生产configure文件。这步可能遇到的错误:
configure.ac:64: error: possibly undefined macro: AC_PROG_LIBTOOL
那么输入命令:
sudo apt-get install autoconf autogen
sudo apt-get install libtool
然后在次运行:
sh auto*.sh
B、按照顺序,依次输入如下命令:
./configure
make check
make install
完成安装。
C、protobuf配置环境变量.
打开profile文件:
sudo vim /etc/profile
export PATH=$PATH:/usr/local/protobuf/bin/
export PKG_CONFIG_PATH=/usr/local/protobuf/lib/pkgconfig/& 保存退出,然后输入命令:
source /etc/profile
D、配置动态链接库
打开配置文件ld.so.conf:
sudo vim /etc/ld.so.conf 添加:
/usr/local/protobuf/libE、更新配置
ldconfig 6、caffe编译:
make all -j8
make pycaffe
OK,万事大吉,打完收工。
相关参考文献:http://blog.csdn.net/realxie/article/details/7456013
/BVLC/caffe/wiki/GeForce-GTX-1080,---CUDA-8.0,---Ubuntu-16.04,---Caffe
/BVLC/caffe/wiki/Ubuntu-16.04-or-15.10-Installation-Guide
http://mooon./928
四、tensorflow
以前的安装方法:
sudo apt-get install python-pip python-dev
export TF_BINARY_URL=/tensorflow/linux/gpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl
sudo pip install --upgrade $TF_BINARY_URL
出现错误:
libcudart.so.7.5: cannot open shared object file: No such file or directory
主要原因是上面的tensoftlow*.whl是cuda7.5编译好的,导致我们不能直接用。因此我们接着要自己编译才行。
1、先装jdk
sudo apt-get update
sudo apt-get install default-jre
sudo apt-get install default-jdk 2、安装编译工具Bazel
echo &deb [arch=amd64] /bazel-apt stable jdk1.8& | sudo tee /etc/apt/sources.list.d/bazel.list
curl /bazel-apt/doc/apt-key.pub.gpg | sudo apt-key add -
sudo apt-get update && sudo apt-get install bazel
3、下载tensorflow并编译
./configure 遇到错误:
Can't find swig.
Ensure swig is in $PATH or set $SWIG_PATH.安装swig:
sudo apt-get install swig
4、在tensorflow安装的时候,没有找到可以忽略使用cudnn的选项,一直提示如下错误:
Please specify the location where cuDNN
library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:
Invalid path to cuDNN
toolkit. Neither of the following two files can be found:
/usr/local/cuda-8.0/lib64/libcudnn.so
/usr/local/cuda-8.0/libcudnn.so
所以没办法,只能把cudnn也给安装了。首先到官网下载cuda8.0对应的cudnn:
cudnn-8.0-linux-x64-v5.0-ga.tgz
tar -zxvf cudnn-8.0-linux-x64-v5.0-ga.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*安装完毕后,就接着前面的工作tensorflow的安装
5、输入.configure,然后一路回车、或者选择yes。
6、这是心酸,原来tensorflow官网给了从源码安装的教程:install &from sources
https://www.tensorflow.org/versions/r0.9/get_started/os_setup.html
参考文献:
/dive-into-tensorflow-part-iii-gtx-1080-ubuntu16-04-cuda8-0-cudnn5-0-tensorflow
**********************作者微博:&&博客:&& 原创文章,转载请保留本行信息********************
cuda8.0+ubuntu16.04+theano、caffe、tensorflow环境搭建 目前自己撘过深度学习各种库、各种环境,已经搭建了n多台电脑,发现每台电脑配置安装方法各不相同,总会出现各不相同的错误,真是心塞
相关阅读排行
相关内容推荐
请激活账号
为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。
您的注册邮箱:
如果您没有收到激活邮件,请注意检查垃圾箱。CUDA使用的GCC版本和现有版本不兼容_Linux教程_Linux公社-Linux系统门户网站
你好,游客
CUDA使用的GCC版本和现有版本不兼容
来源:Linux社区&
作者: Long
安装了最新的gcc 4.7,和 CUDA toolkit4.2,尝试编译后发现错误:
error -- unsupported GNU version! gcc 4.5 and up are not supported!
解决方法使用open 12.1 自带的gcc4.6版本进行编译通过。具体过程如下:
sudo ln -s /usr/bin/gcc-4.6 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-4.6 /usr/local/cuda/bin/g++
相关资讯 & & &
& (05月12日)
& (03月29日)
& (06月22日)
& (05月03日)
& (03月07日)
   同意评论声明
   发表
尊重网上道德,遵守中华人民共和国的各项有关法律法规
承担一切因您的行为而直接或间接导致的民事或刑事法律责任
本站管理人员有权保留或删除其管辖留言中的任意内容
本站有权在网站内转载或引用您的评论
参与本评论即表明您已经阅读并接受上述条款Win7+CUDA8.0+VS2015+Theano0.8配置GPU加速环境
Theano0.8的安装通过Anaconda然后pip install theano,细节参照Theano的官方文档http://deeplearning.net/software/theano/install_windows.html,只要能import theano成功就可以了(或者把文档中的一个sample跑通也可以)。
CUDA直接在下载,照着官方的安装提示一步步来就行,没什么坑。 安装完后可以在cmd下看一下版本(输入nc -V回车即可),然后运行C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\1_Utilities\deviceQuery 下的VS工程文件(参见),编译运行后应该是输出电脑的GPU设备信息等,这就说明CUDA安装成功了!
然后是调用GPU,也是按照先前给的Theano官方文档去做。主要就是新建一个.theanorc.txt(里面的内容找着网上的填就行),然后需要gcc的编译器,我是用了mingw。
我先前由于没有配好VS2015的环境,总是没办法用上GPU,后来参照一些博客如:&&,环境变量配置,具体来说要配置成能够再cmd下直接用cl命令来编译链接.c和.cpp文件。 在此过程中有一个坑,就是配置环境时,添加的PATH、INCLUDE、LIB变量要统一成32位或者64位,我当初PATH设置成(VS安装路径)&/VC/bin (该路径下的cl.exe其实是32位的),而INCLUDE和LIB都是用的x64的,结果一直报错,后来PATH改成了(VS安装路径)&/VC/bin/x86_amd64 才成功。
最后运行Theano官网给出的,速度比单纯使用CPU提升15倍!
Nvidia官网给出的兼容性情况:ubuntu、gtx1080、caffe、cuda8.0、matlab2015b以及遇到的问题
一开始是只菜鸟,linux是啥都闹不清,因为实验室要用caffe研究深度学习,然后自己折腾这玩意不知道折腾了有多久,重装系统不下20次!照着人家的教程来,总也遇见人家遇不见的问题。
一开始是只菜鸟,linux是啥都闹不清,因为实验室要用caffe研究深度学习,然后自己折腾这玩意不知道折腾了有多久,重装不下20次!照着人家的教程来,总也遇见人家遇不见的问题,好多时候解决不了,发现最简便的方法竟然只能是——重装,原谅我只是个菜鸟。满满都是辛酸泪啊。然后要感谢一下网上各种大牛们的教程和对各种问题的解答,现在已经能比较快的重新搭建了,把我收集到觉得有用的资源和我的经验和大家分享一下,希望让更多的新手少走弯路。
本机配置:
gpugtx 1080
cup i7 6800k
系统 Ubuntu14.04 64位
1、装系统(耗时2星期)
步骤:下载安装包(参照上页链接)——制作启动盘——安装(注意如何分区,主分区最多只能有4个;当然也可以直接默认安装,它会自动帮你分好分区。另,有些电脑需要设置优先U盘启动,本机一开始就是默认u盘驱动)
工作站原本装的是win7,最开始想折腾双系统,但是没闹清楚win7是装在硬盘还是固盘里,一不小心就把win7覆盖了。后来有尝试重装双系统,分别装在不同的盘里,无奈ubuntu怎么折腾都不好使,总是卡机什么,最后不得已卸了win7只留了ubuntu。经对比ubuntu14.04比ubuntu16(直接从官网下是在16这个版本)。现在ubuntu只用了固盘,没有用到硬盘,尝试两个盘一起用时,系统老是抽风,原因未知。
安装搜狗输入法,参考
然后参照一步步进行安装,python部分除外——最后本机安的是matlab。中间可能会出现各种问题,需自行百度解决。P.S.请一定按照博文一步步来,因为本纪要省略了一些简单的我也记不住的诸如安装相关依赖库等步骤。
3、安装cuda7.5
到cuda官网自行下载安装包,注意对应到ubuntu 64位,有三个版本可选择,分别是 run、 deb(local)、deb(online)
尝试一:.deb安装
优点:简单快捷。
缺点:因为是打包安装,会自行覆盖原来的显卡驱动,后来一直出现循环登录问题。
解决方法:卸载本机显卡驱动,到英伟达官网下载对应驱动,关掉xserver,后台安装驱动。
尝试二: .run安装
关掉x server(ctri+f1进入后台1,sudo service lightdm stop),运行.run文件(sh xxxx.run),长按回车键接受协议,协议页面之后安装,除了(第一个还是第二个)问是否安装驱动(driver)不接受,其他均按提示选择y或accept,或者输入对应文件夹名。安装完成后打开x server(suervice lightdm start)
4、安装对版本的cudnn以及opencv,系统自带gcc版本为4.8,与cuda7.5兼容。(安装cudasample——如果是.run安装则在安装过程中会提示安装cudasample,不需要重新安装)并验证是否安装成功。安装matlab 并创建快捷方式。
5、下载安装caffe
下载解压,修改Makefile.config。在caffe目录下make all ,make test, make runtest (后缀 &j16表示16条线程加速,编译会更快),全部通过表示caffe安装成功。
出现问题:make runtest出现一个百度不到的错误,邮件英伟达官网,提议重装cuda8。所以,cuda8.0 才是本机的最终归宿,前面的折腾和相关网页链接作为参考(某些步骤还是不变的)
6、重装cuda8.0
从官网下载ubutun 64位对应.run安装包,按照博文(第一页有三个参考)
进行安装。重新在caffe文件夹下make run test ,pass。
问题:我并没有删掉cuda7.5,选择将cuda 8.0建立文件连接cuda之后(cuda7.5安装过程中也会有这个选项),cuda文件夹中不仅有cuda 8的东西,也有cuda 7.5的东西。之后我再删掉cuda7.5的文件夹和相关配置,caffe 又跑不动了。
解决方案:更新与cuda 8.0 对应的opencv和gcc
7、安装opencv3.1和gcc5.3
已经忘记是怎么装的了,开始利用apt-getinstall安装的gcc-5是gcc 5.4,好不容易降级成gcc-5.3之后,却无法再更改gcc版本,就算强行卸载掉所有的gcc-5文件,利用gcc &version查询,依然是gcc-5.3.0,然后就出现各种动态库链接问题,超级崩溃,在stackoverflow(在这里推荐这个国外的网站,用于解决各种问题,港真百度不是那么好用,好多东西都要试好几个答案才行)上求问也没有得到答案。因为caffe 的编译需要更低版本的gcc,最后没有办法只有只好重装系统了。
重装系统就要重装以上所有的东东,请想象我内心有多么崩溃!!!以下为重装步骤,主要参考
http://blog.csdn.net/u/article/details/
两篇博文,亲测可用
1、 重装Ubuntu14.04
2、装sogou拼音(没有中文很难过)
从搜狗官网下载匹配系统(Ubuntu14.04 64位)的deb安装包,点击直接安装,然后在终端输入
然后选择fcitx
终端输入fcitx-config-gtk3
去掉当前选项那个勾,然后搜索sogou,选择搜狗拼音,就可以在屏幕右上角输入法位置看到搜狗拼音的小图标了
3、装gcc 4.9并切换使用
4、安装cuda 8.0
(1)先在cuda官网下载与自己系统对应的.run文件(比deb文件更稳定更好操作),终端输入
cd 安装文件所在文件夹
sudo sh cuda_8.0xxxxxx.run
#第一个选项是问是否安装捆绑的显卡驱动,选择否,其他都选是,根据提示来。如图:
(2)然后添加环境变量
sudo gedit /etc/profile
#在打开的文件中末尾添加以下两行
export PATH=/usr/local/cuda-8.0/bin:$PATH
exportLD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH
#之后保存并退出,在终端执行以下指令使配置生效
sudo ldconfig
(3)验证cuda是否安装成功
进入NVIDIA_CUDA-8.0_Samples文件夹,进行make编译。之后进入1_Utilities/deviceQuery/文件夹,运行./deviceQuery命令,若出现Nvidia显卡的型号等信息,则说明安装成功,如图:
5、安装cudnn5.1
从官网下载cudnn(需注册),版本要与cuda8.0匹配。将下载的压缩文件cudnn-8.0-linux-x64-v5.1.tgz解压得到一个叫做cuda的文件夹,执行以下指令:
sudo cp lib64/lib* /usr/local/cuda-8.0/lib64/
sudo cp include/cudnn.h/usr/local/cuda-8.0/include/
cd/usr/local/cuda/lib64/
sudo chmod 777libcudnn*即可
这里注意,复制完后需要将libcudnn*的权限都改为777,否则后面将不能执行~~~,编译时出现找不到Libcudnn.so或者libcudart.so.8.0文件的情况。
更新文件链接
cd /usr/local/cuda/lib64/
sudo rm -rf libcudnn.so libcudnn.so.5
sudo ln -s libcudnn.so.5.1.5 libcudnn.so.5
sudo ln -s libcudnn.so.5 libcudnn.so
设置环境变量
sudo gedit /etc/profile
#在打开的文件中末尾添加
export PATH=/usr/local/cuda/bin:$PATH
sudo vim /etc/ld.so.conf.d/cuda.conf
#添加文字 /usr/local/cuda/lib64
sudo ldconfig #使配置生效
6、安装opencv3.1
安装基本依赖库
sudoapt-get install build-essential cmake git ibgtk2.0-dev pkg-configlibaodec-dev libavformat-dev libswscale-dev
下载opencv安装包,解压后进入安装文件
cdopencv-3.1.0/modules/cudalegacy/src
sudo gedit graphcuts.cpp
将相关部分替换为
#include "precomp.hpp"
// GraphCut has been removed in NPP 8.0
#if!defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION &= 8000)
void cv::cuda::graphcut(GpuMat&,GpuMat&, GpuMat&, GpuMat&, GpuMat&, GpuMat&, GpuMat&,Stream&) { throw_no_cuda(); }
void cv::cuda::graphcut(GpuMat&,GpuMat&, GpuMat&, GpuMat&, GpuMat&, GpuMat&, GpuMat&,GpuMat&, GpuMat&, GpuMat&, GpuMat&, Stream&) {throw_no_cuda(); }
再次进入安装文件夹
cd opencv-3.1
mkdir build
cmake -DCMAKE_BUILD_TYPE=Release-DCMAKE_INSTALL_PREFIX=/usr/local ..
配置完成后安装
sudo make install
安装完成后查询是否安装成功
pkg-config --modversion opencv
7、安装依赖项
(1)安装atlas
sudo apt-get install libatlas-base-dev
(2)安装矩阵运算库
sudo apt-get install libopenblas-devlibblas-dev liblapack-dev
(3)protobuf库
sudo apt-get install libprotobuf-devprotobuf-compiler
(4)boost库
sudo apt-get installlibboost-all-dev
sudo apt-get installlibgoogle-glog-dev
(6)LMDB与LEVELDB库
sudo apt-getinstall libleveldb-dev liblmdb-dev
(7)snappy库
sudo apt-getinstall libsnappy-dev
sudo apt-get install libhdf5-serial-dev
(9)gflags库
sudo apt-get installlibgflags-dev
(10)opencv库
sudo apt-get installlibopencv-dev
8、安装caffe
从github上克隆一份caffe项目代码并解压。进入caffe 文件夹,复制一份Makefile.config.examples
cp Makefile.config.example Makefile.config
修改其中的一些路径,去掉使用opecv3的注释。如果前边和我说的一致,都选默认路径的话,那么配置文件应该是这个样子
## Refer tohttp://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving ourbuild system are welcome!
# cuDNN acceleration switch (uncomment tobuild with cuDNN).
USE_CUDNN := 1
# CPU-only switch (uncomment to build withoutGPU support).
# CPU_ONLY := 1
# uncomment to disable IO dependencies andcorresponding data layers
# USE_OPENCV := 0
# USE_LEVELDB := 0
# USE_LMDB := 0
# uncomment to allow MDB_NOLOCK when readingLMDB files (only if necessary)
# Youshould not set this flag if you will be reading LMDBs with any
# possibilityof simultaneous read and write
# ALLOW_LMDB_NOLOCK := 1
# Uncomment if you're using OpenCV 3
OPENCV_VERSION := 3
# To customize your choice of compiler,uncomment and set the following.
# N.B. the default for
is g++ and thedefault for OSX is clang++
# CUSTOM_CXX := g++
# CUDA directory contains bin/ and lib/directories that we need.
CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04, if cuda tools are installedvia
# "sudo apt-get installnvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr
# CUDA architecture setting: going with all ofthem.
# For CUDA & 6.0, comment the *_50 linesfor compatibility.
CUDA_ARCH := -gencode arch=compute_20,code=sm_20\
-gencodearch=compute_20,code=sm_21 \
-gencodearch=compute_30,code=sm_30 \
-gencodearch=compute_35,code=sm_35 \
-gencodearch=compute_50,code=sm_50 \
-gencodearch=compute_50,code=compute_50
# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := atlas
# Custom (MKL/ATLAS/OpenBLAS) include and libdirectories.
# Leave commented to accept the defaults foryour choice of BLAS
# (which should work)!
# BLAS_INCLUDE := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas
# Homebrew puts openblas in a directory thatis not on the standard search path
# BLAS_INCLUDE := $(shell brew --prefixopenblas)/include
# BLAS_LIB := $(shell brew --prefixopenblas)/lib
# This is required only if you will compilethe matlab interface.
# MATLAB directory should contain the mexbinary in /bin.
MATLAB_DIR := /usr/local/MATLAB/R2015b
#MATLAB_DIR := /Applications/MATLAB_R2012b.app
# NOTE: this is required only if you willcompile the python interface.
# We need to be able to find .h andnumpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/local/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quitepopular. Include path:
# Verify anaconda location, sometimes it's inroot.
# ANACONDA_HOME := $(HOME)/anaconda
# PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
#$(ANACONDA_HOME)/include/python2.7 \
#$(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \
# Uncomment to use Python 3 (default is Python2)
# PYTHON_LIBRARIES := boost_python3 python3.5m
# PYTHON_INCLUDE := /usr/include/python3.5m \
#/usr/lib/python3.5/dist-packages/numpy/core/include
# We need to be able to find libpythonX.X.soor .dylib.
PYTHON_LIB := /usr/lib
# PYTHON_LIB := $(ANACONDA_HOME)/lib
# Homebrew installs numpy in a non standardpath (keg only)
# PYTHON_INCLUDE += $(dir $(shell python -c'import numpy. print(numpy.core.__file__)'))/include
# PYTHON_LIB += $(shell brew --prefixnumpy)/lib
# Uncomment to support layers written inPython (will link against Python libs)
# WITH_PYTHON_LAYER := 1
# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE)/usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib/usr/lib
# If Homebrew is installed at a non standardlocation (for example your home directory) and you use it for generaldependencies
# INCLUDE_DIRS += $(shell brew--prefix)/include
# LIBRARY_DIRS += $(shell brew --prefix)/lib
# Uncomment to use `pkg-config` to specifyOpenCV library paths.
# (Usually not necessary -- OpenCV librariesare normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1
# N.B. both build and distribute dirs arecleared on `make clean`
BUILD_DIR := build
DISTRIBUTE_DIR := distribute
# Uncomment for debugging. Does not work onOSX due to /BVLC/caffe/issues/171
# DEBUG := 1
# The ID of the GPU that 'make runtest' willuse to run unit tests.
TEST_GPUID := 0
# enable pretty build (comment to see fullcommands)
保存并退出,在caffe文件夹下配置并编译
mkdirbuild
make all -j16
makeruntest
makepycaffe(若要使用python接口)
makematcaffe(若要使用matlab接口)
9、安装matlab
我安装的是MATLAB2015b,百度搜索有许多都是安装MATLAB2014a的,会更稳定,但是只支持gcc 4.7及以下,由于上次安装gcc5.3之后无法切换导致了一系列错误,我决定先安装2015试试,可参照http://blog.csdn.net/lcx/article/details/
sudo mkdir/media/matlab
cd xxxxxx(matlab镜像所在文件夹)
sudo mount -oR2015b_glnxa64.iso /media/matlab
cd/media/matlab
#注意:选择不联网安装,输入crack文件夹中的序列号。然后要使用matlab的接口需要在caffe文件夹下修改Makefile.Configuration,将use matlab前的#注释符去掉。
安装完成后激活
cd/usr/local/MATLAB/R2015b/bin(默认安装目录)
sudo ./matlab #选择不联网,利用crack文件夹下lisence文件激活。激活完成后将crack文件夹下的glnxa64文件夹下的文件copy到 /usr/local/MATLAB/R2015b/bin/glnxa64
cd/usr/local/MATLAB/R2015b/bin
创建快捷方式参照:/Linux/32.htm
遇到的问题
1、循环登录
有时候重启电脑之后进入图形界面输入用户密码却怎么都进不了桌面,又重新弹出登录界面。
解决办法:重装显卡驱动
首先,需要事先在NVIDIA官网下载与自己显卡对应的图形驱动(cuda对显卡有一定的要求,基本上得是n卡才能保证一定跑的起来),保存在电脑某个自己找得到的地方。
遭遇循环登录时,ctrl+f1进入shell主界面,执行以下操作:
cd存放驱动的文件夹
sudo service lightdm stop #关闭图形界面
sudo sh NVIDIA_Linux-xxxxxxx.ru #选择accept、continue 、OK等
sudo service lightdm start
2、查询不到nvcc
装好cuda后利用nvcc &version查询nvcc版本,出现以下提示信息:
Theprogram 'nvcc' is currently not installed. You can install it by typing:
sudoapt-get install nvidia-cuda-toolkit
注意:不要执行提示中的命令
执行sudoapt-get install nvidia-cuda-toolkit后系统会自动安装某个低版本的cuda,当时我手贱,这么试了一下,就装上了cuda5.5,而且找不到对应文件夹,没法删除。
3、键盘错位
由于在安装系统的时候选择了enlish(UK),键盘布局变成了英式,|打出来是#,~打出来是个不知名符号,某些指令也无法打出来了,特别糟心。
解决方法:配置fcitx
参照方案/linux/16832.html
关键是我按照上述网页的方法修改了text input也没有用。经多方折腾,发现原来是没有修改fcitx的配置。我使用的搜狗输入法是建立在在fcitx基础上的。在终端输入
fcitx-config-gtk3
在当前选项中删除english(uk),添加english(us)
4、caffemake出错:/bin/bash: aclocal-1.14: command not found
解决方法:sudo apt-get installautomake
5、apt-get update或导入软件源时出出错:NO_PUBKEY xxxxxxxxxxxxx
安装某些软件时,需要在安装之前导入软件源,如以安装gcc 时提到的sudoadd-apt-repository ppa:ubuntu-toolchain-r/test。有时候会出现如题所示错误
解决方法:导入该秘钥
法1、sudo apt-key adv &recv-keys &keyserver xxxxxxxx(提示缺少的秘钥)
法2、sudo gpg &export &amor xxxxxxxx(秘钥后8位) | sudo apt-key add-
注:若法1出错,出错信息显示能够链接但无法导入,可能是因为端口不对。将网站改为hkp://:80
6、version GLIBXX_3.4.21 not defined in file libstdc++.so.6
解决方法:修改链接文件
sudo gedit /etc/ls.so.conf.d/libc.conf
将 /usr/local/lib改为 /usr/local/lib64
7、caffe make 出错: libprotobuf.so.11 :cannotopen shred object file : no such file or directory
locate libprotobuf.so.11
发现 /usr/local/lib下有该文件而/usr/local/lib下没有
解决方法:修改链接文件
sudo gedit /etc/ld.so.conf
添加下面一行
/include/usr/local/lib64
8、E:could not get lock xxxxxx
解决方法:sudodpkg &configure -a
9、sudo apt-get update出错:Err: trustly Inrelease
解决方法:删除不必要的软件源
法1、从软件和更新(software & updates)中删除不必要的软件源
法2、sudo gedit /etc/apt/source.list
找到以上出错的源,在前加#注释掉
保存并退出,然后执行sudo ldconfig

我要回帖

更多关于 cuda8 gcc 的文章

 

随机推荐