欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ubuntu 18.04安装cuda驱动

程序员文章站 2022-07-03 22:14:37
...

参考 https://www.pugetsystems.com/labs/hpc/How-to-install-CUDA-9-2
-on-Ubuntu-18-04-1184/

  1. 下载Ubuntu18.04 desktop, 制作USB启动,安装

  2. 在Software & Updates"中检查 nvidia驱动,必须是396版
    如果驱动的版本号不对:
    apt purge nvidia*
    add-apt-repository ppa:graphics-drivers/ppa
    sudo apt install nvidia-kernel-source-396
    sudo apt install nvidia-driver-396
    重启电脑

  3. sudo apt-get install freeglut3 freeglut3-dev libxi-dev libxmu-dev
    4.下载17.10的CUDA "run" file installer 然后安装

    sudo sh cuda_9.2.88_396.26_linux.run
    

    You are attempting to install on an unsupported configuration. Do you wish to continue?
    (y)es/(n)o [ default is no ]: y

    Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 396.26?
     (y)es/(n)o/(q)uit: n      !!!!!!!!!重要!!!!!!
    
     Install the CUDA 9.2 Toolkit?
    (y)es/(n)o/(q)uit: y
    
     Enter Toolkit Location
    [ default is /usr/local/cuda-9.2 ]:
    

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

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

    Enter CUDA Samples Location
    [ default is /home/kinghorn ]: /usr/local/cuda-9.2

  4. Install the cuBLAS patch
    wget https://developer.nvidia.com/compute/cuda/9.2/Prod/patches/1/cuda_9.2.88.1_linux
    sudo chmod +x cuda_9.2.88.1_linux.run
    sudo ./cuda_9.2.88.1_linux.run --silent --accept-eula

  5. Setup your environment variables
    To configure the CUDA environment for all users (and applications) on your system create the file (use sudo and a text editor of your choice)
    /etc/profile.d/cuda.sh
    with the following content,
    export PATH=$PATH:/usr/local/cuda/bin
    export CUDADIR=/usr/local/cuda

    Also create the file, /etc/ld.so.conf.d/cuda.conf

    and add the line, /usr/local/cuda/lib64

    Then run: sudo ldconfig

7 重启电脑

  1. Test CUDA by building the "samples"
    编译和运行测试代码
  2. 安装和运行pytorch, gpu 运行
    import torch
    torch.cuda.current_device()
    In [3]: torch.cuda.device(0)

In [4]: torch.cuda.device_count()

In [5]: torch.cuda.get_device_name(0)

上一篇: 摄像头

下一篇: 爆冷教授笑倒学生