如何在Ubuntu 12.04上配置CUDA 4.2
来源:互联网 发布:yum餐厅营运管理系统 编辑:程序博客网 时间:2024/05/16 07:29
今天运行一个UCLA的光流程序,非常耗时间。看到作者在网站上提供了GPU版的,所以希望能使用CUDA加速的版本。今天晚上按照NVidia论坛上的一个教程,成功的配置好了ubuntu 12.04 64bit版的CUDA 4.2. 现将原文分享如下:
http://forums.nvidia.com/index.php?showtopic=231150
Posted 06 June 2012 - 10:40 PM
This post is to give a complete picture on how to install and test CUDA 4.2 on Ubuntu 12.04 64 bit. I have found that everything that needs to be done is quite scattered and needs bringing together to make CUDA more accessible to more novice users such as my self. So if this doesn't work for you please post and let us know and if you know a quicker or better way please enlighten us!!!
Thanks,
CDS
I hope you find this useful and I would like to credit my sources:
FCNS
sn0v
The NVIDIA CUDA Getting Started Guide (Linux)
Note one must have a nVidia GPU which is CUDA capable http://developer.nvidia.com/cuda-gpus
Check is the OS is 32 or 64 bit by runninguname -m
in a terminal. i686 denotes a 32-bit system, and x86_64 denotes a 64-bit one.
Proceed to CUDA Downloads page: http://developer.nvidia.com/cu
For the toolkit, I chose the one titled Ubuntu 11.04, and save all three files in an easy to access location, like your Home folder.
Make sure the requisite tools are installed using the following command :sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
Next, blacklist the required modules (so that they don’t interfere with the driver installation)gksu gedit /etc/modprobe.d/blacklist.conf
Add the following lines to the end of the file, one per line:blacklist amd76x_edac
blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv
Save the file and exit gedit.
In order to get rid of any nVidia residuals, run the following command in a terminal:sudo apt-get remove --purge nvidia*
Once it’s done, reboot your machine. At the login screen, don’t login just yet. PressCtrl+Alt+F1 to switch to a text-based login. Login and switch to the directory which contains the downloaded drivers, toolkit and SDK. Run the following commands:sudo service lightdm stop chmod +x devdriver*.run
Follow the onscreen instructions. If the installer throws up an error about nouveau kernel still running, allow it to create a blacklist for nouveau, quit the installation and reboot. In that case, run the following commands again:sudo service lightdm stop
sudo ./devdriver*.run
The installation should now proceed smoothly. When it asks you if you want the 32-bit libraries and if you want it to editxorg.conf to use these drivers by default, allow both.
Reboot once the installation completes.
Next, enter the following in a terminal window (in the directory where the files are stored):sudo chmod +x cudatoolkit*.run
sudo ./cudatoolkit*.run
where cudatoolkit*.run is the full name of the toolkit installer. I recommend leaving the installation path to its default setting (/usr/local/cuda) unless you have a specific reason for not doing so.
The following lines must be added into the .bashrc file in your home directory:
export PATH=/usr/local/cuda/bin:$PATHexport LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATHexport LD_LIBRARY_PATH=/usr/lib/nvidia-current:$LD_LIBRARY_PATHexport CUDA_ROOT=/usr/local/cuda/bin
SDK must be installed as a regular user (and not as root) to prevent access issues with the SDK files.
Once the toolkit is installed, enter the following in a terminal:sudo chmod +x gpucomputingsdk*.run
sudo ./gpucomputingsdk*.run
where gpucomputingsdk*.run is the full name of the SDK installer. Again, follow the instructions onscreen to complete the installation.
Since there are several linking errors in this compilation several modifications must be make. You are made aware of this when you change your working directory toNVIDIA_GPU_Computing_SDK in your home directory and then run:sudo make
This will result in the following error:
../../lib/librendercheckgl_x86_64.a(rendercheck_gl. cpp.o): In function `CheckBackBuffer::checkStatus(char const*, int, bool)': rendercheck_gl.cpp:(.text+0xfbb): undefined reference to `gluErrorString'
The fix is contained in the following three steps.
1) change the order for all occurrences of RENDERCHECKLIB in BOTH /C/common/common.mk and/CUDALibraries/common/common_cudalib.mk like this:
OLD:LIB += ${OPENGLLIB} $(PARAMGLLIB) $(RENDERCHECKGLLIB) ${LIB} -ldl -rdynamic
NEW:LIB += $(RENDERCHECKGLLIB) ${OPENGLLIB} $(PARAMGLLIB) ${LIB} -ldl –rdynamic
and add -L../../../C/lib in common_cudalib.mk RENDERCHECKGLLIB definition line:
OLD:RENDERCHECKGLLIB := -lrendercheckgl_$(LIB_ARCH)$(LIBSUFFIX)
NEW:RENDERCHECKGLLIB := -L../../../C/lib -lrendercheckgl_$(LIB_ARCH)$(LIBSUFFIX)
2) In all files that use UtilNPP (boxFilterNPP, imageSegmentationNPP,freeImageInteropNPP, histEqualizationNPP), the makefiles have the wrong order of library linking ($LIB is before the source/out files), so go to the/CUDALibraries/src/*NPP/Makefile and change the order like (note this is an example of thefreeImageInteropNPP file modification, all others are done similarly):
OLD:$(CXX) $(INC) $(LIB) -o freeImageInteropNPP freeImageInteropNPP.cpp -lUtilNPP_$(LIB_ARCH) -lfreeimage$(FREEIMAGELIBARCH)
NEW:$(CXX) $(INC) -o freeImageInteropNPP freeImageInteropNPP.cpp $(LIB) -lUtilNPP_$(LIB_ARCH) -lfreeimage$(FREEIMAGELIBARCH)
3) For randomFog, you also need to addUSERENDERCHECKGL := 1
to the Makefile.
Now go back to the working directory NVIDIA_GPU_Computing_SDKand runmake
, this will take some time to fully compile to be patient. Also the compiler will throw several warning but these should be ignored.
The version of the CUDA Toolkit can be checked by runningnvcc -V
in a terminal window. The nvcc command runs the compiler driver that compiles CUDA programs. It calls the gcc compiler for C code and the NVIDIA PTX compiler for the CUDA code.
NVIDIA includes sample programs in source form in the GPU Computing SDK. You should compile them all by changing to~/NVIDIA_GPU_Computing_SDK/Cand runningsudo make
. The resulting binaries will be installed in ~/NVIDIA_GPU_Computing_SDK/C/bin/linux/release.
After compilation, go to ~/NVIDIA_GPU_Computing_SDK/C/bin/linux/release and rundeviceQuery
. If the CUDA software is installed and configured correctly, the output for deviceQuery should look similar to that shown in Figure 1 of thereference guide provided by NVIDIA. The exact appearance and the output lines might be different on your system. The important outcomes are that a device was found (the first highlighted line), that the device matches the one on your system (the second highlighted line), and that the test passed (the final highlighted line). If a CUDA-enabled device and the CUDA Driver are installed but deviceQuery reports that no CUDA-capable devices are present, this likely means that the /dev/nvidia* files are missing or have the wrong permissions.
http://www.bfcat.com/index.php/2012/06/ubuntu-12-04-cuda-4-2/
- 如何在Ubuntu 12.04上配置CUDA 4.2
- 如何在ubuntu上配置QT
- 如何在Ubuntu上配置安装MediaWiki
- Cuda在Ubuntu上的安装
- 在Ubuntu KyLin 14.04上安装CUDA
- CUDA 9.0在Ubuntu上的安装
- 在ubuntu上配置cuda+cudnn+caffe(包括python和matlab接口)+digits
- 在UBUNTU 16.04上配置TensorFlow + cuDNN + CUDA深度学习系统(30分钟傻瓜版)
- 在vs2010上配置cuda环境
- 如何在Ubuntu12.04上安装CUDA
- 如何在ubuntu上配置联通3G上网卡
- 如何在MFC中配置CUDA
- Ubuntu上安装cuda
- 如何在Ubuntu上安装及简单配置SVN
- 如何在ubuntu 15.04服务器上配置SNMPv3?
- 如何在Ubuntu Core上配置自己的WiFi
- 如何在Ubuntu 16.04上安装并配置Redis
- 如何在Ubuntu 16.04上安装并配置Redis
- 十年学会程序设计
- 20121011在期待什么呢
- 数据库MySQL免安装版本在Windows系统上更改数据文件目录
- 未来会怎样
- 我的大学期望
- 如何在Ubuntu 12.04上配置CUDA 4.2
- vc与SQL Server2005 的ADO连接方法
- 出栈序列与Catalan 0-1序列
- 1007
- 挖个坑
- nodejs - redis操作例程
- Android实现推送方式解决方案
- Map-Reduce的过程解析
- 数据库死锁的预防与解除