python How to View pytorch Version
- 2021-10-11 19:11:20
- OfStack
Look at the code ~
import torch
print(torch.__version__)
Supplement: pytorch installation of different versions and version view
1: conda-based installation
conda create --name pytorch_learn python=3.6.7# Create 1 A person named pytorch_learn The environment of
source activate pytorch_learn # Enter the environment
conda install pytorch=0.3.1 cuda80 -c soumith # Installation pytorch0.3.1+ cuda8.0 (You can specify it yourself)
conda install -c soumith torchvision # Installation torchvision
# Install commonly used dependent libraries
conda install pandas
conda install scikit-learn
conda install torchnet
exp:
Installation pyorch1.0 + cuda9.0
conda install pytorch torchvision cudatoolkit=9.0 -c pytorch
2. pip-based installation
Installation cuda8.0+torch1.0+python3.6, You can change the link name to specify the version
pip3 install https://download.pytorch.org/whl/cu80/torch-1.0.1.post2-cp36-cp36m-linux_x86_64.whl
pip3 install torchvision
Step 3 Check & View version
STEP 1 Check
import torch
import torchvision
print(torch.cuda.is_available())
Step 2 View the version
import torch
print(torch.__version__)
4. Possible problems:
Installing pip3
Steps:
Step 1: Install setuptools
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
tar -zxvf setuptools-19.6.tar.gz
cd setuptools-19.6
python3 setup.py build
python3 setup.py install
Step 2: Install pip3
wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
tar -zxvf pip-8.0.2.tar.gz
cd pip-8.0.2
python3 setup.py build
python3 setup.py install