您的位置:首页 > 其它

Ubuntu 14.04(64位)+GTX970+CUDA8.0+Tensorflow配置 (双显卡NVIDIA+Intel集成显卡) ------本内容是长时间的积累,有时间再详细整理

2017-01-18 22:52 676 查看
(后面内容是本人初次玩GPU时,遇到很多坑的问题总结及尝试解决办法。由于买独立的GPU安装会涉及到设备的兼容问题,这里建议还是购买GPU一体机(比如https://item.jd.com/3964771.html),几行代码就可以顺利安装。---2017.10.04)

电脑配置Ubuntu14.04(64位)+GeForceGTX970:



选择安装[b]系统Ubuntu14.04:[/b]

可能电脑配置的不同,在我的机子上这里尝试安装Fedora23,Fedora24,Fedora25,Ubuntu16.04均出现不同程度的问题,问题总结如下:

1.高版本系统,安装GTX970的接口没有信号输出,进入安装界面直接黑屏,显示屏提示没有输入信号,如Ubuntu16.04,Fedora25,但windows系统能够正常启动。

2.fedora低版本(fedora23)安装,开始有信号,然后进入安装时黑屏,或者直接没有信号(Fedora25)。

3.fedora23安装完成后,系统卡死,重启无法登陆。

然后尝试不同的方法解决,比如认为那些黑屏的原因,是由于系统没有带NVIDIA驱动,就现在电脑自带的集成显卡下先安装好驱动,然后再接入GTX970的独立显卡,方法能够让屏幕从无信号转变为有信号黑屏。

从上面的不断装系统尝试,得到几点推断:

1.Windows系统能够正常启动,说明不是GPU的原因,而是系统原因

2.高版本的Fedora25和Ubuntu16.04不能够让GTX970产生信号,当转换到低版本的Fedora时有信号,而且低版本的,这让我们推断是否可以尝试低版本的Fedora和Ubuntu

3.fedora23-25在GTX970上直接没有引导信号,之后在安装驱动后才有信号,但Ubuntu16.04在安装时开始信号正常,只是安装时黑屏,说明低版本的Ubuntu可能更好

因此,这里最后尝试了低版本Ubuntu14.04,安装时正如推断的一样,安装过程十分正常。

Ubuntu下载https://www.ubuntu.com/download/alternative-downloads

系统的前提安装

安装成功Ubuntu14.04后,由于该系统版本较低,缺少一些必要的功能,如Ctrl+Alt+F1(F2-F6)不能进入字符界面tty,但这是cuda安装必要的界面。另外,缺少gcc,g++等编译环境,同时需要对apt-get进行更新,因此建议安装如下内容:

sudosed-i-e's/#GRUB_TERMINAL/GRUB_TERMINAL/g'/etc/default/grub sudoupdate-grub sudoapt-getinstallnautilus-open-terminal sudoapt-getupdate sudoapt-getinstallgccg++linux-headers-$(uname-r) sudoapt-getinstallvim sudoapt-getinstallpython-pippython-dev

安装完之后需要重启reboot,才能进入正常字符界面。 

成功安装Ubuntu14.04系统,安装cuda8.0

在安装cuda8.0,也是费了一番周折,尝试如下:

1.先在NVIDIA官网下载GTX970的显卡驱动安装,



安装时完全按照要求,包括先卸载已有的NVIDIA驱动,停用lightdm。

这里也尝试NVIDIA多次,遇到各种提示错误。最后安装成功后,GPU异常,风扇疯狂旋转,重启无法进入Ubuntu登录界面,并黑屏。

2.安装低版本NVIDIA驱动,如NVIDIA-3.4等,再安装CUDA8.0,并在安装时尝试CUDA8.0时选择是否安装NVIDIAAcceleratedGraphicsDriver,是否安装openGLlibraries,均进行了yes或no的尝试,虽然也能顺利安装,但重启电脑无法进入登录界面,屏幕直接黑屏。

3.由于CUDA8.0自带NVIDIA驱动,在安装时也尝试安装只安装CUDA8.0,而没有在之前另外安装GTX970的驱动。尝试多次,仍然失败。其中一次,安装后在tty界面上可以正常编译和执行NVIDIA_CUDA-8.0_Samples中的例子,但切换到lightdm图形界面,出现黑屏并且用Ctrl+Alt+F1-F6和重启均不能切换回tty界面。

下载cuda8.0驱动

NVIDIA的CUDA官网下载驱动,如我这里下载Ubuntu14.04对应的CUDA8.0的runfile文件NVIDIA-Linux-x86_64-375.26.run



按照官方文档安装CUDA8.0

VerifyYouHaveaCUDA-CapableGPU:

hd@hd:~$lspci|grep-invidia 01:00.0VGAcompatiblecontroller:NVIDIACorporationGM204[GeForceGTX970](reva1) 01:00.1Audiodevice:NVIDIACorporationGM204HighDefinitionAudioController(reva1)

网上有各种安装cuda驱动的教程,可能是各自适用的情况不同,这里强烈建议按照官方文档InstallationGuideforLinux进行安装

主要步骤如下:

1.Performthepre-installationactions. 2.DisabletheNouveaudrivers. 3.Rebootintotextmode(runlevel3). 4.VerifythattheNouveaudriversarenotloaded. 5.Runtheinstallerandfollowtheon-screenprompts: $sudobashcuda_8.0.44_linux.run

  

禁用驱动nouveau

为了安装DisplayDriver,需要禁用驱动nouveau,方法如下:

Ubuntu中新建/etc/modprobe.d/blacklist-nouveau.conf文件

sudovim/etc/modprobe.d/blacklist-nouveau.conf

加入

blacklistnouveau optionsnouveaumodeset=0

保存退出,Regeneratethekernelinitramfs执行

sudoupdate-initramfs-u

使其生效。查看是否禁用成功:

lsmod|grepnouveau

若没有信息,即表明禁用成功。  

禁用图像界面

sudoservicelightdmstop

  

Ubuntu14.04以level3启动设置:

Ubuntu默认是采用level2重启,以图像界面进入,但图像界面是需要在安装cuda驱动之前禁用的,需要登录是直接是以字符界面。

需要采用level3重启,即重启后只进入字符编辑界面tty,这种方法也可以避免重启后直接进入图形界面因黑屏而束手无策。

这里尝试很多方法,有效的方法如下:

首先建立文件/etc/default/grub

sudovi/etc/default/grub

修改GRUB_CMDLINE_LINUX_DEFAULT=”quietsplash”为:

GRUB_CMDLINE_LINUX_DEFAULT=”text”

然后运行下sudoupdate-grub,开机首先进入可启动字符界面

http://blog.csdn.net/jk110333/article/details/17878843

Thesimplerwayistoedit
/etc/init/rc-sysinit.conf
andchange:

envDEFAULT_RUNLEVEL=2

To:

envDEFAULT_RUNLEVEL=N

WhereNisthedesiredrunlevel.

Therunlevelcanbesetusingkernelparameters.Edit
/etc/default/grub
,andchange:

GRUB_CMDLINE_LINUX="

to

GRUB_CMDLINE_LINUX="N"

WhereNistherunlevelyouwant.Thenrun:

sudoupdate-grub

Youcanalsoforceaone-timeboottoadifferentrunlevelbyeditingthecommandlinefromtheGRUBmenuatboot.

http://askubuntu.com/questions/615634/how-to-set-default-runlevel

添加cudnn加速包

下载cudnn加速包,解压将其中文件复制到cuda的安装的对应路径下:

tarxvzfcudnn-8.0-linux-x64-v5.1.tgz#这里要注意你下载的版本,需要解压你下载的对应版本的文件 #解压后的文件夹名字是cuda sudocpcuda/include/cudnn.h/usr/local/cuda/include sudocpcuda/lib64/libcudnn*/usr/local/cuda/lib64 sudochmoda+r/usr/local/cuda/include/cudnn.h/usr/local/cuda/lib64/libcudnn*

添加cuda路径:

新建.bash_profile,

sudogedit~/.bash_profile

在文件中加入

exportLD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64:/usr/local/cuda-8.0/extras/CUPTI/lib64" exportCUDA_HOME=/usr/local/cuda-8.0

关闭,然后对环境变量进行更新

source~/.bash_profile

orPackageManagerInstallation

hd@hd:~$sudogedit~/.profile exportPATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}} hd@hd:~$source~/.profile

hd@hd:~$cat/proc/driver/nvidia/version NVRMversion:NVIDIAUNIXx86_64KernelModule367.57MonOct320:37:01PDT2016 GCCversion:gccversion4.8.4(Ubuntu4.8.4-2ubuntu1~14.04.3)

cd/usr/local/cuda/samples/5_Simulations/smokeParticles sudomake ./smokeParticles



  

安装Tensorflow-GPU版本

Pipinstallation

#Ubuntu/Linux64-bit $sudoapt-getinstallpython-pippython-dev

选择GPU版本Tensorflow并安装

#Ubuntu/Linux64-bit,GPUenabled,Python2.7 #RequiresCUDAtoolkit8.0andCuDNNv5.Forotherversions,see"Installingfromsources"below. $exportTF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.1-cp27-none-linux_x86_64.whl #Python2 $sudopipinstall--upgrade$TF_BINARY_URL

注意:安装是pip可能会出错,采用如下方法对pip进行更新 

$python-mpipinstall--upgradepip

测试Tensorflow的GPU运行效果:

#Using'python-m'tofindtheprograminthepythonsearchpath: $python-mtensorflow.models.image.mnist.convolutional Extractingdata/train-images-idx3-ubyte.gz Extractingdata/train-labels-idx1-ubyte.gz Extractingdata/t10k-images-idx3-ubyte.gz Extractingdata/t10k-labels-idx1-ubyte.gz ...etc...

error:

Initialized! Ftensorflow/stream_executor/cuda/cuda_dnn.cc:221]Checkfailed:s.ok()couldnotfindcudnnCreateincudnnDSO;dlerror:/usr/local/lib/python2.7/dist-packages/tensorflow/python/_pywrap_tensorflow.so:undefinedsymbol:cudnnCreate

解决办法,添加环境变量

exportPATH=/usr/local/cuda/bin:$PATH exportLD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64" exportCUDA_HOME=/usr/local/cuda

CUDA教程有4.4.DeviceNodeVerification,尝试了没有什么卵用

#!/bin/bash /sbin/modprobenvidia if["$?"-eq0];then #CountthenumberofNVIDIAcontrollersfound. NVDEVS=`lspci|grep-iNVIDIA` N3D=`echo"$NVDEVS"|grep"3Dcontroller"|wc-l` NVGA=`echo"$NVDEVS"|grep"VGAcompatiblecontroller"|wc-l` N=`expr$N3D+$NVGA-1` foriin`seq0$N`;do mknod-m666/dev/nvidia$ic195$i done mknod-m666/dev/nvidiactlc195255 else exit1 fi /sbin/modprobenvidia-uvm if["$?"-eq0];then #Findoutthemajordevicenumberusedbythenvidia-uvmdriver D=`grepnvidia-uvm/proc/devices|awk'{print$1}'` mknod-m666/dev/nvidia-uvmc$D0 else exit1 fi

  

 

 receivedanotificationinthefinalinstallmessageaboutthesemissinglibraryfiles:

 http://kmdouglass.github.io/stories/notes/cuda.html

Missingrecommendedlibrary:libX11.so Missingrecommendedlibrary:libXi.so Missingrecommendedlibrary:libXmu.so Missingrecommendedlibrary:libGL.so

有建议创建链接

Tofixthis,createsymlinksin
/usr/lib/
tothecorrespondingfiles:

sudoln-sx86_64-linux-gnu/libX11.solibX11.so sudoln-sx86_64-linux-gnu/libXi.solibXi.so sudoln-sx86_64-linux-gnu/libXmu.solibXmu.so sudoln-sx86_64-linux-gnu/libGL.solibGL.so

有建议安装

sudoapt-getinstallfreeglut3-devbuild-essentiallibx11-devlibxmu-devlibxi-devlibgl1-mesa-glxlibglu1-mesalibglu1-mesa-dev

均尝试也不知道有没有效果 

Ubuntu14.04安装CUDA问题及解决

http://www.cnblogs.com/gaowengang/p/6068788.html 



一般我们可以安装最高版本的专有显卡驱动。也可以在终端里输入下面的命令来查看哪一个专有驱动是推荐安装的。

sudoubuntu-driversdevices



http://www.linuxdiyf.com/linux/28743.html

  

修复unity
在删除了所有提示安装不正确的包后,开始修复unity:
输入命令:
sudoapt-getinstallunity--fix-missing

双显卡处理办法:

http://www.cnblogs.com/gaowengang/p/6068788.html

http://www.linuxwang.com/html/2150.htmlhttps://www.linuxbabe.com/desktop-linux/switch-intel-nvidia-graphics-card-ubuntuhttp://slaytanic.blog.51cto.com/2057708/1630597/

参考了网上这么多关于双显卡的方法,在我的电脑均不行,
Ubuntu16.04下CUDA8环境配置的2种方法http://notes.maxwi.com/2017/02/26/ubuntu-cuda8-env-set/
blos设置,禁用集显,http://www.w10zj.com/Win10xy/Win10yh_522.html
http://forum.ubuntu.org.cn/viewtopic.php?t=476731
IntelIntegratedGraphics,dedicatedGPUforCUDAandUbuntu13.10and14.04
http://osdf.github.io/blog/intel-integrated-graphics-dedicated-gpu-for-cuda-and-ubuntu-1310.html

双显卡解决:安装bumblebee

sudoadd-apt-repositoryppa:bumblebee/stable
sudoapt-getupdate
sudoapt-getinstallbumblebeebumblebee-nvidia

尝试之后虽然可以进入Desktop界面,但NVIDIA驱动和CUDA不能使用,因此这种方法有问题

我的电脑配置:



Graphic:Gallium0.4onllvmpipe(LLVM3.8,128bits)

Software&Updates的AdditionalDrivers界面



YoucanupdateyoursystemwithunsupportedpackagesfromthisuntrustedPPAbyaddingppa:xorg-edgers/ppatoyoursystem'sSoftwareSources.(Readaboutinstalling)

sudoadd-apt-repositoryppa:xorg-edgers/ppa
sudoapt-getupdate


错误http://www.cnblogs.com/xia-Autumn/p/6228911.html

1.libcudart.so.8.0:cannotopensharedobjectfile:Nosuchfileordirectory

======================================================================================

【如果每次开启都显示此错误,则需要打开变量文件设置变量】

打开终端并输入:

sudogedit~/.bashrc

输入用户密码。这时输入的密码是不可见的。

前面的步骤会打开.bashrc文件,在其末尾添加:

exportLD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
exportCUDA_HOME=/usr/local/cuda


使其立即生效,在终端执行:

source~/.bashrc

或者重启电脑即可。

给驱动run文件赋予执行权限http://blog.csdn.net/u012759136/article/details/53355781


sudochmoda+xNVIDIA-Linux-x86_64-375.20.run


安装(注意参数)


sudo./NVIDIA-Linux-x86_64-375.20.run–no-x-check–no-nouveau-check–no-opengl-files



–no-x-check安装驱动时关闭X服务

–no-nouveau-check安装驱动时禁用nouveau

–no-opengl-files只安装驱动文件,不安装OpenGL文件

重启,并不会出现循环登录的问题

所以要手动安装必要的lib,如下,

$sudoapt-getinstallfreeglut3-dev

$sudoapt-getinstalllibxmu-dev

ErrorappearswhenNVIDIA-X-server-settings:





hd@hd:~$vim/etc/default/grub
hd@hd:~$sudoupdate-grub

addnomodesetnogpumanageringrubfile:

#Ifyouchangethisfile,run'update-grub'afterwardstoupdate
#/boot/grub/grub.cfg.
#Forfulldocumentationoftheoptionsinthisfile,see:
#info-fgrub-n'Simpleconfiguration'

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release-i-s2>/dev/null||echoDebian`
GRUB_CMDLINE_LINUX_DEFAULT="quietsplashnomodesetnogpumanager"
GRUB_CMDLINE_LINUX=""

#UncommenttoenableBadRAMfiltering,modifytosuityourneeds
#ThisworkswithLinux(nopatchrequired)andwithanykernelthatobtains
#thememorymapinformationfromGRUB(GNUMach,kernelofFreeBSD...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

#Uncommenttodisablegraphicalterminal(grub-pconly)
#GRUB_TERMINAL=console

#Theresolutionusedongraphicalterminal
#notethatyoucanuseonlymodeswhichyourgraphiccardsupportsviaVBE
#youcanseetheminrealGRUBwiththecommand`vbeinfo'
#GRUB_GFXMODE=640x480

#Uncommentifyoudon'twantGRUBtopass"root=UUID=xxx"parametertoLinux
#GRUB_DISABLE_LINUX_UUID=true

#Uncommenttodisablegenerationofrecoverymodemenuentries
#GRUB_DISABLE_RECOVERY="true"

#Uncommenttogetabeepatgrubstart
#GRUB_INIT_TUNE="4804401"


sudocpcuda_8.0.44_linux.run~/cuda_8.0.44_linux.run
sudoapt-getupdate
sudoapt-getinstallvim
lspci|grep-invidia
sudoapt-getinstalllinux-headers-$(uname-r)
sudoapt-getinstallpython-pippython-dev
systemctlset-defaultmulti-user.target
reboot
sudovim/etc/X11/xorg.conf
exportLD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"

sudoaptinstallgit
gitclonehttps://github.com/tensorflow/tensorflow.gitpython-c"importtensorflow"


hd@hd:~$python-c"importtensorflow"
Itensorflow/stream_executor/dso_loader.cc:135]successfullyopenedCUDAlibrarylibcublas.so.8.0locally
Itensorflow/stream_executor/dso_loader.cc:135]successfullyopenedCUDAlibrarylibcudnn.so.5locally
Itensorflow/stream_executor/dso_loader.cc:135]successfullyopenedCUDAlibrarylibcufft.so.8.0locally
Itensorflow/stream_executor/dso_loader.cc:135]successfullyopenedCUDAlibrarylibcuda.so.1locally
Itensorflow/stream_executor/dso_loader.cc:135]successfullyopenedCUDAlibrarylibcurand.so.8.0locally
hd@hd:~$


sudoservicelightdmstopsudochmoda+xcuda_8.0.44_linux.run
sudo./cuda_8.0.44_linux.run--no-opengl-libs

sudonvidia-xconfig
sudovim/etc/X11/xorg.conf




#nvidia-xconfig:Xconfigurationfilegeneratedbynvidia-xconfig
#nvidia-xconfig:version375.39(buildmeister@swio-display-x86-rhel47-09)TueJan3120:47:44PST2017

Section"ServerLayout"
Identifier"DefaultLayout"
Screen"DefaultScreen"00
InputDevice"Keyboard0""CoreKeyboard"
InputDevice"Mouse0""CorePointer"
EndSection

Section"InputDevice"

#generatedfromdefault
Identifier"Keyboard0"
Driver"keyboard"
EndSection

Section"InputDevice"

#generatedfromdefault
Identifier"Mouse0"
Driver"mouse"
Option"Protocol""auto"
Option"Device""/dev/psaux"
Option"Emulate3Buttons""no"
Option"ZAxisMapping""45"
EndSection

Section"Monitor"
Identifier"Monitor0"
VendorName"Unknown"
ModelName"Unknown"
HorizSync28.0-33.0
VertRefresh43.0-72.0
Option"DPMS"
EndSection

Section"Device"
Identifier"intel"
Driver"intel"
BusID"PCI:0@0:2:0"
Option"AccelMethod""SNA"
EndSection

Section"Screen"
Identifier"DefaultScreen"
Device"intel"
Monitor"Monitor0"
DefaultDepth24
Option"AccelMethod""SNA"
SubSection"Display"
Depth24
Modes"nvidia-auto-select"
EndSubSection
EndSection


http://www.cnblogs.com/gaowengang/p/6068788.html

4本机使用intel集显作为displaycard,而nvidia独显只作为CUDAcomputingcard,建立或修改/etc/X11/xorg.conf文件,内容如下,

Section"Device"

  Identifier"intel"

  Driver"intel"

  BusID"PCI:0@0:2:0"(使用lspci|grep-iintel查询即可)

  Option"AccelMethod""SNA"

EndSection

为防止系统自动修改此文件,打开文件/etc/default/grub,在GRUB_CMDLINE_LINUX_DEFAULT中增加选项"nogpumanager",之后更新grub即可,

$sudoupdate-grub
注意:由于安装时指定了--no-opengl-libs所以安装完成后会warnings如下,

Missingrecommendedlibrary:libGLU.so
Missingrecommendedlibrary:libXi.so
Missingrecommendedlibrary:libXmu.so


  

所以要手动安装必要的lib,如下,

$sudoapt-getinstallfreeglut3-dev

$sudoapt-getinstalllibxmu-dev

Tensorflow(Oldversion):

'target='_blank'>https://github.com/tensorflow/models
Tutorial:

https://www.tensorflow.org/versions/master/get_started/

YoudonotappeartobeusingtheNVIDIAXdriver.PleaseedityourXconfigurationfile(justrun`nvidia-xconfig`asroot),andrestarttheXserver.

Modes"1024×768"是分辨设置。自行添加进去之后,重启即可。

以下是部分内容
Section"Monitor"
Identifier"Monitor0"
VendorName"Unknown"
ModelName"Unknown"
HorizSync31.5-61.0%这个地方修改
VertRefresh50.0-75.0%这个地方修改
Option"DPMS"
EndSection

Section"Device"
Identifier"Device0"
Driver"nvidia"
VendorName"NVIDIACorporation"
EndSection

Section"Screen"
Identifier"Screen0"
Device"Device0"
Monitor"Monitor0"
DefaultDepth24
SubSection"Display"
Depth24
Modes"1024×768"%原先没有这一句添加进去的
EndSubSection
EndSection


  

三intel和NVIDIA双显卡
基本参考:http://www.mintos.org/config/ubuntu-nvidia-prime.html

注意的是我的更新源主服务器和中国服务器附加驱动里都找不到NVIDIA的私有驱动。
所以我参考了其他资料后,查到NVIDIA官网http://www.geforce.cn/drivers最新linux-64位的驱动是340版本
但执行sudoapt-getinstallnvidia-340nvidia-settings-340nvidia-prime

提示我无340nvidia相关包,然后我就改成331提示无nvidia-settings-331包既然是个settings工具我就先不装。
执行sudoapt-getinstallnvidia-331nvidia-prime成功

然后安装完毕,还要安装一个NvidiaPrime双显卡切换指示器,用于在系统托盘中轻点鼠标即可切换显卡,而不必使用命令。在终端中使用如下PPA安装:
sudoadd-apt-repositoryppa:nilarimogard/webupd8
sudoapt-getupdate
sudoapt-getinstallprime-indicator
重启后就看到显卡切换图标了。
在装个命令工具测试fps
须要安装mesa-utils:sudoapt-getinstallmesa-utils
测试指令:glxgears

NVIDIA/Intel核芯显卡显示+Nvidia计算

http://www.cnblogs.com/platero/p/4746285.html

sudovim~/.bashrc

exportLD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
exportCUDA_HOME=/usr/local/cuda
exportPATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
exportLD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
exportLD_LIBRARY_PATH=/usr/lib/nvidia-375
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐
章节导航