Installing CUDA 8.0 + cuDNN 5.1 + TensorFlow with Ubuntu 14.04 (上)

来源:互联网 发布:免费php网站模板 编辑:程序博客网 时间:2024/06/04 19:32

花了一天在Ubuntu 14.04安装CUDA 8.0 + cuDNN 5.1 + TensorFlow,最终成功,记录一下安装过程,方便日后重装。教程大多来自外网,所以就用英文记录,不翻译了。1080 Ti记得在所有步骤走完之后,sudo apt-get update一把,把显卡驱动升级,不然会不识别1080 Ti。

目录:

Installing CUDA 8.0 + cuDNN 5.1 + TensorFlow with Ubuntu 14.04 (上)

Installing CUDA 8.0 + cuDNN 5.1 + TensorFlow with Ubuntu 14.04 (下)


百度云盘链接: https://pan.baidu.com/s/1hsePmWO 密码: 5n1w


Step 1. Installing CUDA 8.0

(1.) Install build essentials.

sudo apt-get install build-essential
(2.) Go to https://developer.nvidia.com/cuda-downloads 或者百度云地址 and download CUDA toolkit 8.0 for Ubuntu 14.04.

(3.) Open up a terminal and extract the separate installers via:

mkdir ~/Downloads/nvidia_installers;cd ~/Downloads./cuda_7.5.18_linux.run -extract=~/Downloads/nvidia_installers;
(4.) Completely uninstall anything in the ubuntu repositories with nvidia-*. I used synaptic and did a purge, AKA completely uninstall programs and configuration.
sudo apt-get --purge remove nvidia-*
(5.) No need to create an xorg.conf file. If you have one, remove it (assuming you have a fresh OS install).
sudo rm /etc/X11/xorg.conf
(6.) Create the /etc/modprobe.d/blacklist-nouveau.conf file with the 2 following lines:
blacklist nouveauoptions nouveau modeset=0
Then do a
sudo update-initramfs -u
(7.) Reboot computer. Nothing should have changed in loading up menu. You should be taken to the login screen. Once there type: Ctrl + Alt + F1, and login to your user. Keep the next commands handy in another machine since now you are in tty.
(8.) In tty:

sudo service lightdm stop

The top line is a necessary step for installing the driver.

(9.) [For Ubuntu 14.04]

sudo sh cuda_8.0.61_375.26_linux.run --no-opengl-libs
(10.) Set Environment path variables in .bashrc:

export PATH=/usr/local/cuda-8.0/bin:$PATHexport LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH
(11.) Verify the driver version:

cat /proc/driver/nvidia/version
(12.) Check CUDA driver version:

nvcc -V
(13.) At this point you can switch the lightdm back on again by doing:
sudo service lightdm start.
(14.) BOTH 16.04 and 14.04
cd /usr/local/cuda/samples/1_Utilities/deviceQuerysudo make./deviceQuery

if you get something wrong, check if there is some device named "nvidia*" in /dev

ls /dev

if not see "nvidia*", use "

touch nvi.shsudo gedit nvi.sh

add the following :

#!/bin/bash/sbin/modprobe nvidiaif [ "$?" -eq 0 ]; then# Count the number of NVIDIA controllers found.NVDEVS=`lspci | grep -i NVIDIA`N3D=`echo "$NVDEVS" | grep "3D controller" | wc -l`NVGA=`echo "$NVDEVS" | grep "VGA compatible controller" | wc -l`N=`expr $N3D + $NVGA - 1`for i in `seq 0 $N`; domknod -m 666 /dev/nvidia$i c 195 $idonemknod -m 666 /dev/nvidiactl c 195 255elseexit 1fi/sbin/modprobe nvidia-uvmif [ "$?" -eq 0 ]; then# Find out the major device number used by the nvidia-uvm driverD=`grep nvidia-uvm /proc/devices | awk '{print $1}'`mknod -m 666 /dev/nvidia-uvm c $D 0elseexit 1fi 

then :

sudo chmod a+x nvi.shsudo ./nvi.sh
run ./deviceQuery again.

Something like this should show up

magneto@magneto-dell:/usr/local/cuda/samples/1_Utilities/deviceQuery$ ./deviceQuery./deviceQuery Starting... CUDA Device Query (Runtime API) version (CUDART static linking)Detected 1 CUDA Capable device(s)Device 0: "Quadro M1000M"  CUDA Driver Version / Runtime Version          8.0 / 7.5  CUDA Capability Major/Minor version number:    5.0  Total amount of global memory:                 2002 MBytes (2099642368 bytes)  ( 4) Multiprocessors, (128) CUDA Cores/MP:     512 CUDA Cores  GPU Max Clock rate:                            1072 MHz (1.07 GHz)  Memory Clock rate:                             2505 Mhz  Memory Bus Width:                              128-bit  L2 Cache Size:                                 2097152 bytes  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers  Total amount of constant memory:               65536 bytes  Total amount of shared memory per block:       49152 bytes  Total number of registers available per block: 65536  Warp size:                                     32  Maximum number of threads per multiprocessor:  2048  Maximum number of threads per block:           1024  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)  Maximum memory pitch:                          2147483647 bytes  Texture alignment:                             512 bytes  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)  Run time limit on kernels:                     No  Integrated GPU sharing Host Memory:            No  Support host page-locked memory mapping:       Yes  Alignment requirement for Surfaces:            Yes  Device has ECC support:                        Disabled  Device supports Unified Addressing (UVA):      Yes  Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0  Compute Mode:     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 8.0, CUDA Runtime Version = 7.5, NumDevs = 1, Device0 = Quadro M1000MResult = PASS
Done!!

References:

https://www.pugetsystems.com/labs/hpc/NVIDIA-CUDA-with-Ubuntu-16-04-beta-on-a-laptop-if-you-just-cannot-wait-775/
https://devtalk.nvidia.com/default/topic/878117/cuda-setup-and-installation/-solved-titan-x-for-cuda-7-5-login-loop-error-ubuntu-14-04-/
http://askubuntu.com/questions/451672/installing-and-testing-cuda-in-ubuntu-14-04

0 0