Windows+NVIDIA GeForce 940MX+Pyt

2019-04-06  本文已影响0人  georgeguo

环境说明

说明:10.1版本(cuda_10.1.105_418.96_win10.exe)没有安装成功,降低到9.0安装成功,具体原因不详,我觉得可能是显卡太LOW了。

安装cuda

安装PyTorch

conda install pytorch torchvision cudatoolkit=9.0 -c pytorch

快速测试(本机已经安装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)

快速链接

上一篇 下一篇

猜你喜欢

热点阅读