• pytorch安装与入门(一)


     好久没有更新pytorch,这次更新做个笔记

    1.安装CUDA

    https://developer.nvidia.com/cuda-toolkit-archive

     

    设置环境变量后输入nvcc -V

    C:UsersWQBin>nvcc -V
    nvcc: NVIDIA (R) Cuda compiler driver
    Copyright (c) 2005-2019 NVIDIA Corporation
    Built on Fri_Feb__8_19:08:26_Pacific_Standard_Time_2019
    Cuda compilation tools, release 10.1, V10.1.105

     2.安装pytorch

    • PyTorch on Windows only supports Python 3.x

    2.1解决慢到无法装的问题

    最有效方法是添加镜像源,常见的清华或中科大。先查看是否已经安装相关镜像源,windows系统在cmd窗口中执行命令:

    conda config --show

    使用【conda config --add channels 】添加清华数据源

    channels:
      - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
      - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/
      - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

    安装:

    conda install pytorch torchvision cudatoolkit=10.1

    测试pytorch

    >>> import torch
    >>> torch.cuda.is_available()
    True

    如果是false原因可能是:

    >>> from __future__ import print_function
    >>> import torch
    >>> x = torch.rand(5, 3)
    >>> print(x)
    tensor([[0.1863, 0.4498, 0.0765],
            [0.6291, 0.2132, 0.5534],
            [0.8320, 0.9772, 0.7931],
            [0.8859, 0.9128, 0.0536],
            [0.5445, 0.5895, 0.1608]])
    >>>  

    其他注意事项:

    1.要求电脑的显卡驱动大于396.26。输入 nvidia-smi,查看自己的 Driver Version。

    (deeplearning) C:UsersWQBin>nvidia-smi
    Sat Apr 11 11:45:39 2020
    +-----------------------------------------------------------------------------+
    | NVIDIA-SMI 445.75       Driver Version: 445.75       CUDA Version: 11.0     |
    |-------------------------------+----------------------+----------------------+
    | GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
    | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
    |===============================+======================+======================|
    |   0  GeForce GTX 1060   WDDM  | 00000000:01:00.0 Off |                  N/A |
    | N/A   45C    P8     6W /  N/A |     92MiB /  6144MiB |      0%      Default |
    +-------------------------------+----------------------+----------------------+
    
    +-----------------------------------------------------------------------------+
    | Processes:                                                                  |
    |  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
    |        ID   ID                                                   Usage      |
    |=============================================================================|
    |  No running processes found                                                 |
    +-----------------------------------------------------------------------------+

    完美。。开始搞事情

  • 相关阅读:
    发送邮件失败Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535
    文件上传报错:Current request is not a multipart request
    Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback.
    IDEA——错误: 找不到或无法加载主类 com.Main
    浅识微服务架构
    ConcurrentHashMap底层实现原理(JDK1.8)源码分析
    Tiled Editor 图块的两种导入方式
    TileMap Editer 编辑器工具介绍
    Tiled 地图编辑器使用教程-官方demo
    log4net 基础
  • 原文地址:https://www.cnblogs.com/wqbin/p/12678525.html
Copyright © 2020-2023  润新知