SoFunction
Updated on 2024-12-20

python how to check pytorch version

Look at the code.

import torch
print(torch.__version__)

Supplementary: pytorch different version installation and version view

I: Conda-based installation

conda create --name pytorch_learn python=3.6.7#Create an environment named pytorch_learn
source activate pytorch_learn # Access to the environment
conda install pytorch=0.3.1 cuda80 -c soumith # Install pytorch0.3.1+ cuda8.0 (you can specify yourself)
conda install -c soumith torchvision # Install torchvision
# Installing common related dependency libraries
conda install pandas
conda install scikit-learn
conda install torchnet

exp:
mountingpyorch1.0 + cuda9.0
conda install pytorch torchvision cudatoolkit=9.0 -c pytorch

II. Installation based on pip

mountingcuda8.0+torch1.0+python3.6,Link name can be changed to specify version
pip3 install /whl/cu80/torch-1.0.1.post2-cp36-cp36m-linux_x86_64.whl
pip3 install torchvision

III. Checking & viewing versions

1. Inspection

import torch
import torchvision
print(.is_available())

2. View Version

import torch
print(torch.__version__)

IV. Problems that may be encountered:

Install pip3

Steps:

Step 1: Install setuptools

wget --no-check-certificate /packages/source/s/setuptools/setuptools-19.#md5=c607dd118eae682c44ed146367a17e26
tar -zxvf setuptools-19.
cd setuptools-19.6
python3  build
python3  install

Step 2: Install pip3

wget --no-check-certificate /packages/source/p/pip/pip-8.0.#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
tar -zxvf pip-8.0.
cd pip-8.0.2
python3  build
python3  install

The above is a personal experience, I hope it can give you a reference, and I hope you can support me more. If there is any mistake or something that has not been fully considered, please do not hesitate to advise me.