pytorch使用经验 持续更新

一、ubuntu18 安装

#安装环境

1 操作系统:Linux ai-System-Product-Name 5.0.0-37-generic #40~18.04.1-Ubuntu SMP Thu Nov 14 12:06:39 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

2、驱动:
pytorch使用经验 持续更新

3 python

   pytorch使用经验 持续更新

4 pip 

#国内好的源 https://pypi.tuna.tsinghua.edu.cn/simple

另附 国内清华大学开源镜像网站

https://mirrors.tuna.tsinghua.edu.cn/

永久修改

ubuntu  :修改或创建 ~/.pip/pip.conf

在pip.conf中 添加:

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

#更新pip3 pip3 install --upgrade pip 

#pip3 错误

 File "/usr/bin/pip3", line 9, in <module>
    from pip import main: ImportError: cannot import name 'main'

找到对应版本python目录下面的pip目录 修改 __main__.py文件

#from pip._internal.main import main as _main  # isort:skip # noqa 屏蔽此行
from pip import main #改为这行
if __name__ == '__main__':
    sys.exit(_main())

# pip Cannot uninstall ‘numpy’  It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall 解决办法

pip3  install 安装包 --upgrade --ignore-installed 安装包

#安装pytorch1.3

1 pip3 install -i  https://pypi.tuna.tsinghua.edu.cn/simple torch

pytorch使用经验 持续更新

官方源安装

git clone --recursive https://github.com/pytorch/pytorch

2 pytorch 相关安装

pip3 install -i  https://pypi.tuna.tsinghua.edu.cn/simple torchvision

pip3 install -i  https://pypi.tuna.tsinghua.edu.cn/simple  -U torch torchvision cython

 

#使用pytorch

1 看是否使用gpu

torch.cuda.is_available()