经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 数据库/运维 » Linux/Shell » 查看文章
Ubuntu18.04安装完应该做的一些事 显卡驱动安装和cuda8.0
来源:cnblogs  作者:Piilu  时间:2019/3/22 8:49:21  对本文有异议

  博主装Ubuntu18.04主要是为了用于跑深度学习,所以我们先来搞搞gcc环境

第一步:安装多版本gcc、g++可切换

  1. sudo apt-get install gcc-4.8 gcc-4.8-multilib
  2. sudo apt-get install g++-4.8 g++-4.8-multilib
  3. sudo apt-get install gcc-5 gcc-5-multilib
  4. sudo apt-get install g++-5 g++-5-multilib
  5. sudo apt-get install gcc-6 gcc-6-multilib
  6. sudo apt-get install g++-6 g++-6-multilib
  7. sudo apt-get install gcc-7 gcc-7-multilib
  8. sudo apt-get install g++-7 g++-7-multilib
  9. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 48
  10. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50
  11. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60
  12. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70
  13. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 48
  14. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 50
  15. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 60
  16. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 70

  切换版本命令

  1. sudo update-alternatives --config gcc
  2. sudo update-alternatives --config g++

  根据自己想要的环境选择

第二步:准备安装显卡驱动和cuda8.0等相关文件

  最新cuda8.0 及其补丁
  cuda_8.0.61.2_linux.run 
  cuda_8.0.61_375.26_linux.run
  最新支持cuda8.0的CUDNN
  libcudnn7_7.1.4.18-1+cuda8.0_amd64.deb
  libcudnn7-dev_7.1.4.18-1+cuda8.0_amd64.deb
  libcudnn7-doc_7.1.4.18-1+cuda8.0_amd64.deb
  cuda8.0 安装包解压文件
  /001/InstallUtils.pm(从cuda_8.0.61.2_linux.run中解压出来的文件,后面会讲到)
第三步:安装显卡驱动
  • 1、开机 nomodeset 进入系统
    • 开机进引导界面 第一项 按e 进入配置启动
    • 在quiet splash - - -后加上 nomodeset
    • 按F10 保存 进入系统
  1. quiet splash - - -
  2. quiet splash nomodeset
  • 2、禁用系统自带NVIDIA驱动
  1. sudo vim /etc/modprobe.d/blacklist.conf
  2. # 在文件尾加入
  3. blacklist nouveau
  4. options nouveau modeset=0
  5. # 保存并退出 执行下面命令 更新引导
  6. sudo update-initramfs u
  • 3、安装 NVIDIA 驱动
  1. # 切换gcc 版本 到gcc-5 以上 (使用高版本感觉会好一点)
  2. # 查看支持的驱动版本
  3. ubuntu-drivers devices
  4. # 安装驱动
  5. sudo ubuntu-drivers autoinstall
  6. # 根据查询的版本安装比较保险 例如
  7. sudo apt-get install nvidia-driver-390
  8. # 装驱动 需要关闭 安全启动
  • 5、重启系统
  1. sudo reboot
  2. # 查看NVIDIA驱动 使用情况
  3. nvidia-smi
  • 6、安装cuda8.0
    • 安装依赖
    1. sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
    • 切换gcc版本到 4.8
    1. sudo update-alternatives --config gcc
    • 解压cuda8.0
    1. sh cuda_8.0.61_375.26_linux.run --noexec --target 001
    2. # 将runfile文件解压并且放到001文件夹中
    3. # 将InstalUtil.pm 拷贝到 /etc/perl/
    4. sudo cp InstalUtil.pm /etc/perl/
    • 安装cuda8.0及补丁
    1. # 可选 加运行权限
    2. chmod u+x cuda_8.0.61_375.26_linux.run
    3. chmod u+x cuda_8.0.61.2_linux.run
    4. # 运行
    5. sudo ./chmod u+x cuda_8.0.61_375.26_linux.run
    6. Do you accept the previously read EULA?
    7. accept/decline/quit: accept
    8. You are attempting to install on an unsupported configuration. Do you wish to continue?
    9. (y)es/(n)o [ default is no ]: y
    10. Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
    11. (y)es/(n)o/(q)uit: n
    12. Install the CUDA 8.0 Toolkit?
    13. (y)es/(n)o/(q)uit: y
    14. Enter Toolkit Location
    15. [ default is /usr/local/cuda-8.0 ]:
    16. Do you want to install a symbolic link at /usr/local/cuda?
    17. (y)es/(n)o/(q)uit: y
    18. Install the CUDA 8.0 Samples?
    19. (y)es/(n)o/(q)uit: y
    20. Enter CUDA Samples Location
    21. [ default is /home/deep ]:
    22. # 安装补丁
    23. sudo ./cuda_8.0.61.2_linux.run
    • 添加环境变量
    1. cd
    2. vim .bashrc
    3. # 添加到文件尾部
    4. export PATH=/usr/local/cuda-8.0/bin:$PATH
    5. export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64$LD_LIBRARY_PATH
    6. # 保存 退出
    7. sudo su
    8. source .bashrc
    • 重启系统
    1. sudo reboot
    • 安装cudnn
    1. sudo dpkg -i libcudnn7_7.1.4.18-1+cuda8.0_amd64.deb
    2. sudo dpkg -i libcudnn7-dev_7.1.4.18-1+cuda8.0_amd64.deb
    3. sudo dpkg -i libcudnn7-doc_7.1.4.18-1+cuda8.0_amd64.deb
    • 查看cuda版本和cudnn版本
    1. # cuda 版本
    2. cat /usr/local/cuda/version.txt
    3. # cudnn 版本
    4. cat /usr/include/x86_64-linux-gnu/cudnn_v7.h | grep CUDNN_MAJOR -A 2
    • 编译
    1. # 不用编译全部 只编译deviceQuery
    2. cd /home/deep/NVIDIA_CUDA-8.0_Samples/1_Utilities/deviceQuery
    3. make
    • 测试
    1. ./deviceQuery
    2. # 出现显卡信息
    3. ./deviceQuery Starting...
    4. CUDA Device Query (Runtime API) version (CUDART static linking)
    5. Detected 1 CUDA Capable device(s)
    6. Device 0: "GeForce GTX 1080"
    7. CUDA Driver Version / Runtime Version 9.1 / 8.0
    8. CUDA Capability Major/Minor version number: 6.1
    9. Total amount of global memory: 8116 MBytes (8510701568 bytes)
    10. (20) Multiprocessors, (128) CUDA Cores/MP: 2560 CUDA Cores
    11. GPU Max Clock rate: 1734 MHz (1.73 GHz)
    12. Memory Clock rate: 5005 Mhz
    13. Memory Bus Width: 256-bit
    14. L2 Cache Size: 2097152 bytes
    15. Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
    16. Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
    17. Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers
    18. Total amount of constant memory: 65536 bytes
    19. Total amount of shared memory per block: 49152 bytes
    20. Total number of registers available per block: 65536
    21. Warp size: 32
    22. Maximum number of threads per multiprocessor: 2048
    23. Maximum number of threads per block: 1024
    24. Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
    25. Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
    26. Maximum memory pitch: 2147483647 bytes
    27. Texture alignment: 512 bytes
    28. Concurrent copy and kernel execution: Yes with 2 copy engine(s)
    29. Run time limit on kernels: Yes
    30. Integrated GPU sharing Host Memory: No
    31. Support host page-locked memory mapping: Yes
    32. Alignment requirement for Surfaces: Yes
    33. Device has ECC support: Disabled
    34. Device supports Unified Addressing (UVA): Yes
    35. Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0
    36. Compute Mode:
    37. < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
    38. deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 9.1, CUDA Runtime Version = 8.0, NumDevs = 1, Device0 = GeForce GTX 1080
    39. Result = PASS

     

如果出现相应的显卡信息表示安装成功了。

 

 

 

原文链接:http://www.cnblogs.com/sleepylulu/p/10574230.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号