GGzero 佳佳象棋 论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 42|回复: 0

Ubuntu 16.04 上安装 CUDA 9.0和cuDNN v7.0.5 (Dec 5, 2017)

[复制链接]

164

主题

331

帖子

1160

积分

特级大师

Rank: 12Rank: 12Rank: 12

积分
1160
发表于 2020-1-12 20:22:04 | 显示全部楼层 |阅读模式
在安装之前,建议先浏览一下官方的安装文档,以下的安装步骤也是这样来的。(https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html)
一、CUDA 9.0安装安装前检查:1. Verify You Have a CUDA-Capable GPU$ lspci | grep -i nvidia
2.Verify You Have a Supported Version of Linux$ uname -m && cat /etc/*release
  You should see output similar to the following, modified for your particular system:
x86_64Red Hat Enterprise Linux Workstation release 6.0 (Santiago)
  The x86_64 line indicates you are running on a 64-bit system.
3. Verify the System Has gcc Installed$ gcc --version
  If an error message displays, you need to install the development tools from your Linux distribution or obtain a version of gcc and its accompanying toolchain from the Web.
  参考另一篇博客,可以使用如下命令进行安装:
sudo apt-get install build-essential
4. Verify the System has the Correct Kernel Headers and Development Packages Installed(1)查看系统版本:
$ uname -r
(2)在终端输入:
$ sudo apt-get install linux-headers-$(uname -r)
可以安装对应kernel版本的kernel header和package development
结果显示:
......
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 4 个软件包未被升级。
表示系统里已经有了,不用重复安装。
若以上各项验证检查均满足要求,便可进行下面的正式安装过程。如果没有满足要求的话,可以参考cuda的官方文档,里面有详细的针对每个问题的解决方案。
开始安装:  这里选择runfile安装,首先从官网下载对应版本的runfile文件,这里下载的是cuda 9.0版本。
  下载完后,用MD5 检验,如果序号不和,需要重新下载。
$ md5sum cuda_9.0.176_linux.run
1.禁用nouveau驱动(1)在如下目录创建文件
/etc/modprobe.d/blacklist-nouveau.conf
文件中的内容为:
blacklist nouveauoptions nouveau modeset=0
(2)执行如下命令:
$ sudo update-initramfs -u
2.重启电脑,进入登录界面的时候,不要登录进入桌面(否则可能会失败,若不小心进入,请重启电脑),直接按Ctrl+Alt+F1进入文本模式(命令行界面),登录账户。3.输入 $ sudo service lightdm stop 关闭图形化界面4.切换到cuda安装文件的路径,并执行如下命令:$ sudo sh cuda_9.0.176_linux.run
5.然后就进入安装过程,开始都是End User License Agreement,你可以CTRL +C 跳过,然后accept,下面就是安装的交互界面,开始的Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 367.48?选择n,因为你已经安装驱动了。Using more to view the EULA.End User License Agreement--------------------------Preface-------The following contains specific license terms and conditionsfor four separate NVIDIA products. By accepting thisagreement, you agree to comply with all the terms andconditions applicable to the specific product(s) includedherein.NVIDIA CUDA ToolkitDescriptionThe NVIDIA CUDA Toolkit provides command-line and graphicaltools for building, debugging and optimizing the performanceof applications accelerated by NVIDIA GPUs, runtime and mathlibraries, and documentation including programming guides,user manuals, and API references. The NVIDIA CUDA ToolkitLicense Agreement is available in Chapter 1.Default Install Location of CUDA ToolkitWindows platformo you accept the previously read EULA?accept/decline/quit: acceptInstall NVIDIA Accelerated Graphics Driver for Linux-x86_64 367.48?(y)es/(n)o/(q)uit: nInstall the CUDA 8.0 Toolkit?(y)es/(n)o/(q)uit: yEnter 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: yInstall the CUDA 8.0 Samples?(y)es/(n)o/(q)uit: y Enter CUDA Samples Location [ default is /home/kinny ]: Installing the CUDA Toolkit in /usr/local/cuda-8.0 ...Missing recommended library: libXmu.soInstalling the CUDA Samples in /home/kinny ...Copying samples to /home/kinny/NVIDIA_CUDA-8.0_Samples now...Finished copying samples.============ Summary ============Driver:   Not SelectedToolkit:  Installed in /usr/local/cuda-8.0Samples:  Installed in /home/kinny, but missing recommended librariesPlease 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 rootTo uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/binPlease 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 -driverLogfile is /tmp/cuda_install_17494.log
6.配置cuda环境变量export PATH="$PATH:/usr/local/cuda-8.0/bin"export LD_LIBRARY_PATH="/usr/local/cuda-8.0/lib64"nvidia-smi
结果出现以下输出,说明配置成功






二、安装 cuDNN v7.0.5 (Dec 5, 2017), for CUDA 9.01、进入cudnn下载页面,找到cuda 9.0对应的cudnn版本,有不同的版本可以选择,这里用的是 cuDNN v7.0.5。(https://developer.nvidia.com/rdp/cudnn-archive
2、选择安装方式,有两种方式可以选择,一个是Tar文件安装,一个是Debian文件安装。
  这里建议选择Tar文件方式进行安装。我最开始用Debian方式安装,结果安装失败,后面改用Tar文件安装,安装成功。
  首先,下载Tar文件文件,选择如下选项下载:







  然后,将下载下来的tar文件进行解压:
$ tar -xzvf cudnn-9.0-linux-x64-v7.tgz
  接下来,在命令终端执行如下操作:
$ sudo cp cuda/include/cudnn.h /usr/local/cuda/include$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64$ sudo chmod a+r /usr/local/cuda/include/cudnn.h/usr/local/cuda/lib64/libcudnn*
  安装结束。
参考:
1、https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
2、https://developer.download.nvidia.com/compute/machine-learning/cudnn/secure/v7.0.5/prod/Doc/cuDNN-Installation-Guide.pdf?F3g1KdjFNYdiLJij-scgwW_WEl1bB36K3_6RXs4hVMIBuA4fONuQXiUhm8KYaiHCJ4ZOuqAVZ5tB6D8VKSnR2qLmwtp7LmB9_I5flrHeLNwmN8OV6pqrkuroZXrVIk6DTPHSbNzJd1NZpcmGUExpit-iIy4qPy4o3QhNf-_DuGX7RGPJHN2P53yFYb53WN6mCw
3、https://blog.csdn.net/qlulibin/article/details/78714596
4、https://www.cnblogs.com/xia-Autumn/p/6228911.html



作者:haoshengup
链接:https://www.jianshu.com/p/e087bc0cd934
来源:简书



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|GGzero 佳佳象棋 论坛 ( 苏ICP备18047470号-1

GMT+8, 2020-1-28 05:57 , Processed in 0.022474 second(s), 5 queries , Redis On.

Powered by Discuz! 4.2

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表