RedHat(rhel5.5_x86-client)下配置CUDA開發環境

一、安裝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)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章