Windows+NVIDIA GeForce 940MX+Pytorch搭建深度學習運行環(huán)境

環(huán)境說明

  • 硬件環(huán)境:Thinkpad T460p, 顯卡:NVIDIA GeForce 940MX(很low的顯卡,勉強學習用用)
  • 操作系統(tǒng):Win10
  • cuda版本:cuda_9.0.176_win10.exe,下載鏈接。

說明:10.1版本(cuda_10.1.105_418.96_win10.exe)沒有安裝成功,降低到9.0安裝成功,具體原因不詳,我覺得可能是顯卡太LOW了。

安裝cuda

  • 1、右鍵cuda_9.0.176_win10.exe,以管理員的身份運行,點擊安裝(最好退出360)。

  • 2、安裝裝過程中會出現(xiàn)以下提示:勾選"I understand,and wish to continue the installation regradless"。


    cuda安裝1.png
  • 3、cmd=>nvcc --version 測試是否安裝成功

安裝PyTorch

  • 1、選擇pythorch版本,根據(jù)主頁提供的選項,勾選之后會自動生成對應的下載鏈接。
  • 2、我本機已經(jīng)安裝了Anaconda,所以我選擇的生成的安裝命令如下(直接在線安裝):
conda install pytorch torchvision cudatoolkit=9.0 -c pytorch

快速測試(本機已經(jīng)安裝Pycharm)

# -*- coding: utf-8 -*- 

import torch
import time

if __name__ == "__main__":
    print(torch.__version__)
    print(torch.cuda.is_available())

    a = torch.randn(10000, 1000)
    b = torch.randn(1000, 2000)

    t0 = time.time()
    c = torch.matmul(a, b)
    print("cpu: ", time.time() - t0)

    device = torch.device('cuda')
    a = a.to(device)
    b = b.to(device)

    t0 = time.time()
    c = torch.matmul(a, b)
    print("gpu1: ", time.time() - t0)

    t0 = time.time()
    c = torch.matmul(a, b)
    print("gpu2: ", time.time() - t0)

快速鏈接

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容