http://fedoraproject.org/wiki/Cuda
首先請先確認自己機子的顯卡是否爲Nvidia的顯卡和型號
lspci|grep VGA然後到ftp://download.nvidia.com/XFree86/Linux-x86_64/290.10/README/supportedchips.html查看,如果你的顯卡在
1. 切換到root用戶
su -
2. 確定當前linux內核及SELinux policy 是否爲最新
yum update kernel* selinux-policy*
如果有升級過程,就重啓一下
reboot
重啓後會出現設置頁面,不用管,一路foward
3.安裝rpmfushion源
su -c 'yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm'
4. 安裝GeForce 6/7/8/9/200/300/400/500 系列顯卡的nVidia驅動
這裏提供 akmod, kmod及kmod-PAE三種安裝方式。
akmod方式出現的問題少並且非常容易,如果您使用
- 自己編譯的內核
- 舊的fedora內核
- 經常升級及測試中變換內核
推薦這種akmod安裝方式。
注(譯者就是使用akmod安裝方式)
您在以下三種安裝方式先其一。
akmod-nvidia安裝方式:
- yum install akmod-nvidia xorg-x11-drv-nvidia-libs
- ##Extra package for kernel-PAE users
- yum install kernel-PAE-devel
kmod-nvidia安裝方式:
- yum install kmod-nvidia xorg-x11-drv-nvidia-libs
kmod-PAE安裝方式
- kmod-nvidia-PAE and kernel-PAE-devel
- yum install kernel-PAE-devel kmod-nvidia-PAE
5. 刪除Fedora官方自帶的nouveau顯卡驅動
- ##備份原來的 initramfs nouveau image鏡像 ##
- mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img
- ## 創建新的 initramfs image鏡像 ##
- dracut /boot/initramfs-$(uname -r).img $(uname -r)
6. 所有安裝已經完成,重新啓動機器
- reboot
Prerequisites
First, be sure your GPU is compatible with CUDA. Refer to Nvidia's list of CUDA GPUs.
Then, install required packages:
su -c 'yum install wget make gcc-c++ freeglut-devel libXi-devel libXmu-devel mesa-libGLU-devel'
Install NVIDIA libraries
If you want to run BOINC projects, you will also need the NVIDIA drivers and libraries available in the "rpmfusion" repository.
- See ForbiddenItems#NVIDIA for Fedora's official policy on the NVIDIA drivers (which is why the "nouveau" graphics driver instead of the "nvidia" one is used by default.)
- See rpmfusion configuration on how to activate the "rpmfusion" repository for your installation.
- See xorg-x11-drv-nvidia on what the RPM fusion "xorg-x11-drv-nvidia" package is about and how to install it.
The "rpmfusion" repository provides several RPM packages:
- The "nvidia" graphics driver, which replaces the "nouveau" driver.
- Two configuration tool packages.
- The NVIDIA library packages. There are 32-bit and 64-bit versions. You need to install both the 32 bit and 64 bit library packages if you are on a 64 bit machine otherwise some BOINC projects won't run.
- The NIVIDA kernel module package. This package is adapted to a specific kernel and needs to be updated whenever your system is updated to a new kernel (see below).
This illustration (made with Gliffy) depicts the packages and their interdependencies. It is sufficient to install the library packages to pull them all in, including the correct kernel module package:
On 32 bit:
su -c 'yum install xorg-x11-drv-nvidia-libs'
On 64 bit:
su -c 'yum install xorg-x11-drv-nvidia-libs xorg-x11-drv-nvidia-libs.i686' if (ERROR) then su -c 'rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm' su -c 'rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm'
After installation, check the list of provided libraries using "rpm --query --list xorg-x11-drv-nvidia-libs | grep -P '\.so(\.[123])?$'
"
/usr/lib64/nvidia/libGL.so.1 /usr/lib64/nvidia/libOpenCL.so.1 /usr/lib64/nvidia/libXvMCNVIDIA.so.1 /usr/lib64/nvidia/libcuda.so /usr/lib64/nvidia/libcuda.so.1 /usr/lib64/nvidia/libnvcuvid.so.1 /usr/lib64/nvidia/libnvidia-cfg.so.1 /usr/lib64/nvidia/libnvidia-compiler.so.1 /usr/lib64/nvidia/libnvidia-glcore.so /usr/lib64/nvidia/libnvidia-glcore.so.1 /usr/lib64/nvidia/libnvidia-ml.so.1 /usr/lib64/nvidia/libnvidia-opencl.so.1 /usr/lib64/nvidia/libnvidia-tls.so.1 /usr/lib64/nvidia/tls/libnvidia-tls.so /usr/lib64/nvidia/tls/libnvidia-tls.so.1 /usr/lib64/vdpau/libvdpau_nvidia.so /usr/lib64/vdpau/libvdpau_nvidia.so.1 /usr/lib/nvidia/libGL.so.1 /usr/lib/nvidia/libOpenCL.so.1 /usr/lib/nvidia/libXvMCNVIDIA.so.1 /usr/lib/nvidia/libcuda.so /usr/lib/nvidia/libcuda.so.1 /usr/lib/nvidia/libnvcuvid.so.1 /usr/lib/nvidia/libnvidia-cfg.so.1 /usr/lib/nvidia/libnvidia-compiler.so.1 /usr/lib/nvidia/libnvidia-glcore.so /usr/lib/nvidia/libnvidia-glcore.so.1 /usr/lib/nvidia/libnvidia-ml.so.13.5.2-3.fc17.x86_64 /usr/lib/nvidia/libnvidia-opencl.so.1 /usr/lib/nvidia/libnvidia-tls.so.1 /usr/lib/nvidia/tls/libnvidia-tls.so /usr/lib/nvidia/tls/libnvidia-tls.so.1 /usr/lib/vdpau/libvdpau_nvidia.so /usr/lib/vdpau/libvdpau_nvidia.so.1
Upgrading your kernel
After a 'yum update' that upgraded the kernel, booting will not work because the 'nvidia' kernel module for the new kernel version is missing and the 'nouveau' kernel module has been blacklisted via file '/etc/modprobe.d/blacklist-nouveau.conf'.
To fix this, log in as root, then:
- Determine the version code of your next kernel (it should be the highest version code in '/boot', e.g. '3.5.4-2.fc17.x86_64').
- Store this version code in a shell variable for ease-of-use:
NEXT=3.5.4-2.fc17.x86_64
. - Add the new 'kmod-nvidia' package from the rpmfusion repository to your system by running
yum install "kmod-nvidia-${NEXT}"
This will add the kernel module as '/usr/lib/modules/${NEXT}/extra/nvidia/nvidia.ko'. - After that, you may have to recreate the initial RAM disk as well (not sure here, this may be needed on first installation only) using
mv /boot/initramfs-${NEXT}.img /boot/initramfs-${NEXT}.old
and thendracut /boot/initramfs-${NEXT}.img ${NEXT}
See also this thread on fedoraforum.org
Download CUDA Toolkit and GPU Computing SDK
You will have to download the installers for the "CUDA Toolkit" and for the "GPU Computing SDK". Refer to theNvidia CUDA downloads page for the latest versions.
Let's download and save them on the Desktop.
32 bit :
cd ~/Desktop wget http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/cudatoolkit_4.2.9_linux_32_fedora14.run wget http://developer.download.nvidia.com/compute/cuda/4_2/rel/sdk/gpucomputingsdk_4.2.9_linux.run
64 bit :
cd ~/Desktop wget http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/cudatoolkit_4.2.9_linux_64_fedora14.run wget http://developer.download.nvidia.com/compute/cuda/4_2/rel/sdk/gpucomputingsdk_4.2.9_linux.run
Install CUDA Toolkit
Go to "Desktop", add execution permissions of the cudatoolkit downloaded file, and execute it with root permissions:
cd ~/Desktop chmod +x cudatoolkit_4.2.9_linux_* su -c './cudatoolkit_4.2.9_linux_*'
When it asks you:
Enter install path (default /usr/local/cuda, '/cuda' will be appended):
type:
/opt
Install GPU Computing SDK
As before, go to "Desktop", add execution permissions of the gpucomputingsdk downloaded file, and execute itwithout root permissions:
cd ~/Desktop chmod +x gpucomputingsdk_4.2.9_linux.run ./gpucomputingsdk_4.2.9_linux.run
When it asks you:
Enter install path (default ~/NVIDIA_GPU_Computing_SDK):
press [enter] (to use default path)
When it asks you:
Enter CUDA install path (default /usr/local/cuda):
type
/opt/cuda
Preparation
Executable search path
Extend the executable search path to include CUDA executables:
export PATH=$PATH:/opt/cuda/bin
To make this permanent, modify your ~/.bashrc
(modifying ~/.bash_profile
will cause the path to be extended for the login shell only):
echo 'export PATH=$PATH:/opt/cuda/bin' >> ~/.bashrc
Library search path
Extend the library search path to include CUDA libraries:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/cuda/lib:/opt/cuda/lib64
To make this permanent, modify your ~/.bashrc
:
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/cuda/lib:/opt/cuda/lib64' >> ~/.bashrc
Or more correctly, add entries to /etc/ld.so.conf.d/
, then run
ldconfig
once:
su -c 'echo "/opt/cuda/lib" > /etc/ld.so.conf.d/nvidia-cuda.conf; echo "/opt/cuda/lib64" > /etc/ld.so.conf.d/nvidia-cuda64.conf ; ldconfig'
If you later want to check whether any of your programs need something that isn't there, run this command in the relevant directory:
find . -exec file --mime '{}' ';' | grep 'application/x-executable' | cut --fields=1 --delimiter=':' | xargs ldd | grep 'not found'
Fedora 17
Some compatibility problems appeared with gcc-4.7. You will have to install a compatibility version:
su -c 'yum install compat-gcc-34 compat-gcc-34-c++'
Create a symbolic link to make CUDA use gcc-3.4:
su -c 'ln -s /usr/bin/gcc34 /opt/cuda/bin/gcc'
Now, you can compile.
32bits:
cd ~/NVIDIA_GPU_Computing_SDK/C LINKFLAGS=-L/usr/lib/nvidia/ make cuda-install=/opt/cuda
64bits:
cd ~/NVIDIA_GPU_Computing_SDK/C LINKFLAGS=-L/usr/lib64/nvidia/ make cuda-install=/opt/cuda
Test
Now, let's test if CUDA is working correctly. Type:
~/NVIDIA_GPU_Computing_SDK/C/bin/linux/release/fluidsGL
You should see something like this on the command line:
[fluidsGL] starting... [fluidsGL] - [OpenGL/CUDA simulation] starting... OpenGL device is Available CUDA device [GeForce GT 610] has 1 Multi-Processors
A window with a fluid dynamics simulation should appear. Use the mouse pointer to generate some activity:
Now we can use GPUGRID applications with BOINC.
If the following error message appears instead:
[fluidsGL] starting... [fluidsGL] - [OpenGL/CUDA simulation] starting... OpenGL device is NOT Available, [fluidsGL] exiting... [fluidsGL] test results... WAIVED
You are probably running the application as a user that does not currently have access to the display.
There are additional test programs underneath ~/NVIDIA_GPU_Computing_SDK/C/bin/linux/release/
. Try a few.
In particular
~/NVIDIA_GPU_Computing_SDK/C/bin/linux/release/deviceQuery
will tell you about the capabilities of the graphics device:
Device 0: "GeForce GT 610" CUDA Driver Version / Runtime Version 5.0 / 4.2 CUDA Capability Major/Minor version number: 2.1 Total amount of global memory: 1024 MBytes (1073283072 bytes) ( 1) Multiprocessors x ( 48) CUDA Cores/MP: 48 CUDA Cores GPU Clock rate: 1620 MHz (1.62 GHz) Memory Clock rate: 667 Mhz Memory Bus Width: 64-bit L2 Cache Size: 65536 bytes Max Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536,65535), 3D=(2048,2048,2048) Max Layered Texture Size (dim) x layers 1D=(16384) x 2048, 2D=(16384,16384) x 2048 Total amount of constant memory: 65536 bytes Total amount of shared memory per block: 49152 bytes Total number of registers available per block: 32768 Warp size: 32 Maximum number of threads per multiprocessor: 1536 Maximum number of threads per block: 1024 Maximum sizes of each dimension of a block: 1024 x 1024 x 64 Maximum sizes of each dimension of a grid: 65535 x 65535 x 65535 Maximum memory pitch: 2147483647 bytes Texture alignment: 512 bytes Concurrent copy and execution: Yes with 1 copy engine(s) Run time limit on kernels: Yes Integrated GPU sharing Host Memory: No Support host page-locked memory mapping: Yes Concurrent kernel execution: Yes Alignment requirement for Surfaces: Yes Device has ECC support enabled: No Device is using TCC driver mode: No Device supports Unified Addressing (UVA): Yes Device PCI Bus ID / PCI location ID: 2 / 0 Compute Mode: < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
Cleanup
Now that CUDA has been installed, the installers files are useless. You can remove them:
cd ~/Desktop rm cudatoolkit_4.2.9_linux_* rm gpucomputingsdk_4.2.9_linux.run
Uninstall
If you want to totally remove CUDA, juste delete the /opt/cuda and~/NVIDIA_GPU_Computing_SDK folders:
rm -r ~/NVIDIA_GPU_Computing_SDK su -c 'rm -r /opt/cuda'
and remove the export PATH=$PATH:/opt/cuda/bin
and export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/cuda/lib:/opt/cuda/lib64
lines of the~/.bash_profile file.