Ubuntu14.04安装cuda8.0&&CUDNN

安装显卡驱动
https://blog.csdn.net/jhszh418762259/article/details/52957166
卸载已有驱动
apt-get remove --purge nvidia*
下载显卡驱动?
https://www.nvidia.com/Download/index.aspx?lang=en-us
 

1 安装前的检查
安装CUDA之前,首先要做一些事情,检查你的机器是否可以安装CUDA。

1.1 检查你的gpu是否是可以安装CUDA 的
运行如下命令:

$ lspci | grep -i nvidia

这个是我的机器的返回结果:

01:00.0 VGA compatible controller: NVIDIA Corporation GM107 [GeForce GTX 750 Ti] (rev a2)
01:00.1 Audio device: NVIDIA Corporation Device 0fbc (rev a1)

1.2 检查你的linux版本是否支持CUDA
运行如下命令:

 uname -m && cat /etc/*release

我的机器返回结果如下:

x86_64
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.2 LTS"
NAME="Ubuntu"
VERSION="14.04.2 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.2 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
DISTRIB_ID=Ubuntu Kylin
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu Kylin 14.04"

x86_64代表你的机器是64位的,剩下的是解释的linux发行版信息。

如果是红帽,可能是这样的信息:

x86_64 
Red Hat Enterprise Linux Workstation release 6.0 (Santiago)

CUDA只支持一些特定的linux发行版,有Fedora,OpenSuSE,RHEL,CentOS,SLES,Ubuntu.

1.3 验证操作系统是否安装了gcc
在使用CUDA Tookit 开发的时候,gcc是需要的,但是运行CUDA程序的时候不需要。

gcc -v

我的结果是:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.3-12ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --enable-objc-gc --with-cloog --enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-12ubuntu1) 

1.4 验证linux内核是否有正确的系统头文件
输入:

uname -r

结果为:

3.16.0-53-generic

如果没有出现结果,就需要如下命令进行安装:

apt-get install linux-headers-$(uname -r)

2 安装CUDA-Toolkit
点击官网链接:CUDA-Toolkit ,在Select Target Platform里,点击linux,86_64,Ubuntu,14.04,deb[network],之后网页会自动弹出来安装指令:

Installation Instructions:
dpkg -i cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64.deb
apt-get update
apt-get install cuda

dpkg -i cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64.deb 遇到如下错误:

dpkg-deb: error: `cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64.deb' is not a debian format archive
dpkg: error processing archive cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64.deb (--install):
 subprocess dpkg-deb --control returned error exit status 2
Errors were encountered while processing:
 cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64.deb

官网下载这个包并运行:

./cuda_8.0.61_375.26_linux.run

Do you accept the previously read EULA?
accept/decline/quit:accept


Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
(y)es/(n)o/(q)uit: n


Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: y


Enter Toolkit Location
 [ default is /usr/local/cuda-8.0 ]: 


Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y


Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: y


Enter CUDA Samples Location
 [ default is /home/explorer ]: 


Installing the CUDA Toolkit in /usr/local/cuda-8.0 ...
Missing recommended library: libGLU.so
Missing recommended library: libX11.so
Missing recommended library: libXi.so
Missing recommended library: libXmu.so


Installing the CUDA Samples in /home/explorer ...
Copying samples to /home/explorer/NVIDIA_CUDA-8.0_Samples now...
Finished copying samples.


===========
= Summary =
===========


Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-8.0
Samples:  Installed in /home/explorer, but missing recommended libraries


Please make sure that
 -   PATH includes /usr/local/cuda-8.0/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root


To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin


Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.


***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 361.00 is required for CUDA 8.0 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
    sudo <CudaInstaller>.run -silent -driver


Logfile is /tmp/cuda_install_2925.log

重新开始:

dpkg -i cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64.deb
apt-get update
apt-get install cuda

如无意外就安装成功了,下面设置环境变量。 
vim ~/.bashrc 
在后面添加:

export CUDA_HOME=/usr/local/cuda-8.0
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH
export PATH=/usr/local/cuda-8.0/bin:$PATH

保存退出,刷新source ~/.bashrc。

查看版本:nvcc -V
 

# install cudnn


tar -xf cudnn-8.0-linux-x64-v6.0.tgz
cp cuda/include/* /usr/local/cuda/include/
cp cuda/lib64/* /usr/local/cuda/lib64/
rm -r -f cuda
echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/cuda/lib64" | sudo tee -a /etc/profile

重启服务器:nvidia-smi 测试

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值