--index-url to install pytorch

Hi everyone,
I was wondering why pytorch is installed relying on custom repositories with pip.
Pytorch must be installed as:

pip install torch --index-url https://download.pytorch.org/whl/cu121

There different repositories for different cuda versions or cpu.
This is a nightmare when specifiying pytorch as a requirement in python packages. Pretty much impossible to define dynamically (i.e. let the user choose a cuda version or cpu).

Jax on contrary nicely solves this enabling cuda as an extra: pip install jax[cuda_12]

That’s not true as pip install torch will install the latest stable PyTorch wheel with CUDA 12.1 dependencies.
Nightly binaries, wheels with older (or newer) CUDA runtimes, non-Linux, etc. are hosted on custom S3 buckets.

Indeed, but that’s the case only for linux.


For windows it’s the other way around and default is cpu.
And still offering the possibility of using cpu or gpu+cuda is really hard using index-url when making packages.

1 Like