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                                                 |
    +-----------------------------------------------------------------------------+

    完美。。开始搞事情

  • 相关阅读:
    python uiautomator,比 appium 更简单的 app 测试工具
    Python 经典面试题(一)
    python 虚拟环境配置
    python 路径操作工具 pathlib,比 os 模块好用太多
    如何使用python records 库优雅的操作数据库
    使用 tablib 来自动化管理测试用例,其他的工具都不用学了
    allure 这么高大上的测试报告环境,5 分钟搞定
    学会这些 pycharm 编程小技巧,编程效率提升 10 倍
    stack,unstack,groupby,pivot_table的区别
    count(),列表推导式,transpose()
  • 原文地址:https://www.cnblogs.com/wqbin/p/12678525.html
Copyright © 2011-2022 走看看