Linux install pytorch and view version

Linux install pytorch

Install command

# Python 2.7
pip install https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp27-cp27mu-linux_x86_64.whl
pip install torchvision
# if the above command does not work, then you have python 2.7 UCS2, use this command
pip install https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp27-cp27m-linux_x86_64.whl

# Python 3.5
pip3 install https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp35-cp35m-linux_x86_64.whl
pip3 install torchvision

# Python 3.6
pip3 install https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp36-cp36m-linux_x86_64.whl
pip3 install torchvision

# Python 3.7
pip3 install https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp37-cp37m-linux_x86_64.whl
pip3 install torchvision

Verification example

#进入python指令界面
$ python
Python 3.6.8 (default, Oct  7 2019, 12:59:55) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> x = torch.rand(5, 3)
>>> print(x)
tensor([[0.5126, 0.5629, 0.0852],
        [0.6154, 0.0131, 0.1205],
        [0.2580, 0.5730, 0.9639],
        [0.4405, 0.3427, 0.4881],
        [0.5466, 0.6256, 0.7592]])

>>> 

View pytorch version

#进入python指令界面
$ python
Python 3.6.8 (default, Oct  7 2019, 12:59:55) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
#导入torch
>>> import torch
#torch.__version__查看版本号
>>> print (torch.__version__)
1.4.0
>>> 

Guess you like

Origin blog.csdn.net/CFH1021/article/details/105197606