ubuntu 18.04安裝cuda驅(qū)動

參考 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驅(qū)動,必須是396版
    如果驅(qū)動的版本號不對:
    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)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容