RedHat(rhel5.5_x86-client)下配置CUDA开发环境

来源:互联网 发布:中信证券手机版软件 编辑:程序博客网 时间:2024/06/17 06:16
一、安裝centos yum.
安装软件库yum是必不可少的,红帽中运行yum指令会出现”This system is not registered with RHN”的提示。
原因是你的linux没有在红帽网络上注册,所以无法下载上面的软件包,替代方案可以使用centos,下面介绍下使用centos 的流程:
1.卸载rhel的默认安装的yum包
查看yum包
rpm -qa|grep yum
卸载之
rpm -qa|grep yum|xargs rpm -e --nodeps
2.下载新的yum包
wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm
wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm
并且安装之
rpm -ivh yum-*
注意:1、yum和yum-fastestmirror相互依赖,所以同时安装即可;2、有时直接运行指令可能会出现无法找到路径的情况,原因可能有两个:1)rhel为i386版本,将路径中的x86_64替换为i386,2)yum软件版本升级原版本被替换掉。不论怎样,可以在浏览器输入:http://centos.ustc.edu.cn/centos/5/os/,进入对应目录找到自己需要的包,即可解决问题。
3.下载yum的配置源
wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo 下载到 /etc/yum.repos.d/ 目录下面,不必修改文件名。
4.运行yum makecache生成缓存

二、安裝显卡驱动devdriver_4.2_linux_64_295.41.run
进入bios将pci设备显卡设置为Nvidia显卡启动,/sbin/init 3(或Ctrl+Alt+Backspace)进入命令行模式,sh devdriver_4.2_linux_64_295.41.run。
期间,没有安装gcc或有其它问题会出现错误提示:
安装gcc:yum install gcc
安装g++:yum install gcc-c++.x86_64
内核版本问题:首先看了内核版本:
uname -r
2.6.18-164.11.1.el5xen
原来是xen的内核,这种内核是装不上nvidia的驱动的(网上说的)
yum install kernel kernel-devel
reboot
在开机时选择上面装的内核启动
init 3
进入命令界面
sh NVIDIA-Linux-x86-190.53-pkg1.run
一路YES下去,哈哈,终于安装成功!
如果看到报错信息中有”gcc”方面的错,应该是你gcc没有安装
yum install gcc

三、安装需要用到的其他开发包
yum install wget make gcc-c++ freeglut-devel libXi-devel libXmu-devel mesa-libGLU-devel

四、安装cudatoolkit_4.2.9_linux_64_rhel5.5和sdk gpucomputingsdk_4.2.9_linux.run(CUDA5.0之后,toolkit和sdk集成到了一个安装包中,并且集成了一个在Linux下开发CUDA程序非常好用的集成开发环境NSight),cuda最新版本,可以关注网址:https://developer.nvidia.com/cuda-downloads
在GUI中sh cudatoolkit_4.2.9_linux_64_rhel5.5.run
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib:$LD_LIBRARY_PATH

如果想永久保存环境,写入文件~/.bash_profile,source .bash_profile使其生效。
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/cuda/bin
LD_LIBRARY_PATH==/usr/local/cuda/lib64
export PATH
unset USERNAME

五、关于运行程序出现error while loading shared libraries: libcudart.so.4:错误提示的问题:
vi etc/profile文件加以下两行:
PATH=${PATH}:/usr/local/cuda/bin/
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib(lib64)
修改后,执行
$source /etc/profile
然后在etc/ld.so.conf.d目录中添加cuda.conf文件(如已存在,可以检查是否为以下内容):
/usr/local/cuda/lib64
(我的目录中没有这个文件,sudo gedit 新建了一个)
修改好文件后,别忘了重载环境变量哦~
ldconfig
source /etc/profile
之后连着执行了n个示例程序,均成功执行。

 

最后要刷新系统的动态连接库配置

libcrypto.so.0.9.8
#vim /etc/ld.so.conf
在文末插入一行 /usr/local/ssl/lib
# ldconfig -v 


六、安装toolkit和sdk成功后注意出现的提示:
* Please make sure your PATH includes /usr/local/cuda/bin
* Please make sure your LD_LIBRARY_PATH
*   for 32-bit Linux distributions includes /usr/local/cuda/lib
*   for 64-bit Linux distributions includes /usr/local/cuda/lib64:/usr/local/cuda/lib
* OR
*   for 32-bit Linux distributions add /usr/local/cuda/lib
*   for 64-bit Linux distributions add /usr/local/cuda/lib64 and /usr/local/cuda/lib
* to /etc/ld.so.conf and run ldconfig as root

* Please read the release notes in /usr/local/cuda/doc/

* To uninstall CUDA, remove the CUDA files in /usr/local/cuda
* Installation Complete
export LD_LIBRARY_PATH=/usr/local/cuda/lib:$LD_LIBRARY_PATH

* Please make sure your PATH includes /usr/local/cuda/bin
* Please make sure your LD_LIBRARY_PATH includes:
*   for 32-bit Linux distributions: /usr/local/cuda/lib
*   for 64-bit Linux distributions: /usr/local/cuda/lib64 and /usr/local/cuda/lib

* To uninstall the NVIDIA GPU Computing SDK, please delete /root/NVIDIA_GPU_Computing_SDK
* Installation Complete


2013.3.21
(转载请注明出处:http://blog.csdn.net/wu070815/article/details/8191549)
原创粉丝点击