ubuntu18.04 配置cuda

参考链接

安装nvidia显卡驱动:

  1. bios下disable secure boot
  2. 禁用nouveau

sudo gedit /etc/modprobe.d/blacklist.conf
在最后一行加上: blacklist nouveau
sudo update-initramfs -u

  1. roboot后执行命令lsmod | grep nouveau,若没有输出则禁用成功(可在无图形界面的命令模式查看)
  2. ubuntu-drivers devices
    若没有输出,则执行
    sudo add-apt-repository ppa:graphics-drivers/ppa
    sudo apt update
    
  3. 卸载原有驱动: sudo apt-get purge nvidia*
  4. 确保 gcc、g++ 版本在4.9及以上
  5. sudo ubuntu-drivers autoinstall
  6. 如果安装后发现是 CUDA Version: N/A,如图
    此时torch会无法使用gpu,如图
    需要到官方网站下载驱动,通过bash命令安装
    sudo bash Downloads/NVIDIA-Linux-x86_64-450.57.run --no-x-check –no-nouveau-check –no-opengl-files
    过程中遇到:
    Would you like to run the nvidia-xconfig utility to automatically update your X configuration file so that the NVIDIA X driver will be used when you restart X? Any pre-existing X configuration file will be backed up.
    选No,其他的一路yes

.bashrc文件添加的是

export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"

Error:

  1. 安装驱动出现Bad return status for module build on kernel: 4.15.0-109-generic
    • 查看下一行的log文件,来百度具体的error,很有可能是gcc、g++版本问题
  2. there is enough space in /tmp
    .run文件没下完整,重下一遍即可
  3. Missing recommended library: libGLU.so
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev
  1. cannot find Toolkit in /usr/local/cuda-8.0 参考
mkdir cuda-8
sudo sh cuda_8.0.61_375.26_linux.run --noexec --target cuda-8
cp cuda-8/InstallUtils.pm /usr/share/perl5

卸载cuda

在/usr/local/cuda/bin 目录下,有cuda 自带的卸载工具uninstall_cuda_9.1.pl

cd /usr/local/cuda/bin
sudo ./uninstall_cuda_9.1.pl

查看当前cuda版本

nvcc --version

查看当前cudnn版本

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容