Windows+NVIDIA GeForce 940MX+Pytorch搭建深度学习运行环境

环境说明

  • 硬件环境:Thinkpad T460p, 显卡:NVIDIA GeForce 940MX(很low的显卡,勉强学习用用)
  • 操作系统: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、安装装过程中会出现以下提示:勾选"I understand,and wish to continue the installation regradless"。


    cuda安装1.png
  • 3、cmd=>nvcc --version 测试是否安装成功

安装PyTorch

  • 1、选择pythorch版本,根据主页提供的选项,勾选之后会自动生成对应的下载链接。
  • 2、我本机已经安装了Anaconda,所以我选择的生成的安装命令如下(直接在线安装):
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)

快速链接

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容