環(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)
快速鏈接
- 英偉達驅(qū)動:https://www.geforce.cn/drivers
- pytorch版本選擇:https://pytorch.org/get-started/locally/
- bilibili pytorch入門教程:(https://www.bilibili.com/video/av49008640?p=4)