zoukankan      html  css  js  c++  java
  • 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                                                 |
    +-----------------------------------------------------------------------------+

    完美。。开始搞事情

  • 相关阅读:
    微软软件下载
    FTP主动连接与被动连接
    Linux下grep显示前后几行信息
    cacti 安装过程中“ERROR: 您的MySQL TimeZone 数据库未被填充. 请在继续之前填入此数据库.”
    Cacti安装详细步骤
    Linux 踢掉其他终端用户
    迁移设备存储报的错误及解决方式
    sql_mode :(STRICT_TRANS_TABLES与STRICT_ALL_TABLES 区别)
    Nginx日志按日期切割详解(按天切割)
    git pull冲突:commit your changes or stash them before you can merge.
  • 原文地址:https://www.cnblogs.com/wqbin/p/12678525.html
Copyright © 2011-2022 走看看