How to upgrade torchvision without upgrading torch?

My torch and torchvision version:

(pytorchfromsource) dai@jqkj-EG820G-G10:~/scripts$ python
Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchvision
>>> import torch
>>> torch.__version__
'1.2.0.dev20190527'
>>> torchvision.__version__
'0.2.1'

I want to upgrade torchvision to 0.2.1 to use pretrained MobileNetv2, but when I’m upgrading torchvision through pip, torch is also upgrading.

(pytorchfromsource) dai@jqkj-EG820G-G10:~/scripts$ pip install torchvision==0.4.1
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting torchvision==0.4.1
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fc/23/d418c9102d4054d19d57ccf0aca18b7c1c1f34cc0a136760b493f78ddb06/torchvision-0.4.1-cp36-cp36m-manylinux1_x86_64.whl (10.1MB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 10.1MB 2.9MB/s
Requirement already satisfied: numpy in /home/jqkj/miniconda3/envs/pytorchfromsource/lib/python3.6/site-packages (from torchvision==0.4.1) (1.16.3)
Requirement already satisfied: six in /home/jqkj/miniconda3/envs/pytorchfromsource/lib/python3.6/site-packages (from torchvision==0.4.1) (1.12.0)
Requirement already satisfied: pillow>=4.1.1 in /home/jqkj/miniconda3/envs/pytorchfromsource/lib/python3.6/site-packages (from torchvision==0.4.1) (6.0.0)
Collecting torch==1.3.0 (from torchvision==0.4.1)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ae/05/50a05de5337f7a924bb8bd70c6936230642233e424d6a9747ef1cfbde353/torch-1.3.0-cp36-cp36m-manylinux1_x86_64.whl (773.1MB)
     |β–ˆβ–Š                              | 42.6MB 737kB/s eta 0:16:31^C

How can I upgrade torchvision without upgrading torch?

Looking forward to your replay.

Sorry, I found the solution myself:

pip install torchvision==0.4.1 --no-deps
3 Likes

Just git clone torchvision repo and build what you want. It’s very simple.