Package: pytorch-pip-shim
pytorch-pip-shimpackagecodetestsWhat is it?Why do I need it?How do I install it?How do I use it?How do I uninstall it?How do I configure it?How does it work?DisclaimerNeither this project (pytorch-pip-shim) nor its author
(Philip Meier) are affiliated withPyTorchin any way. PyTorch and any related
marks aretrademarks of Facebook, Inc.What is it?pytorch-pip-shimis a small background utility that eases the installation process
withpipfor PyTorch and third-party packages that depend on its distributions.
After the shim is inserted, you can install PyTorch withpiplike you do with any
other package.Why do I need it?PyTorch is fullypip installable, but PyPI, the defaultpipsearch index, has
some limitations:PyPI regularly only allows binaries up to a size ofapproximately 60 MB. You
canrequest a file size limit increase(and the PyTorch team probably did that), but it is still not enough: the Windows
binaries cannot be installed throughPyPIdue to their size.PyTorch uses local version specifiers to indicate for which computation backend the
binary was compiled, for exampletorch==1.6.0+cpu. Unfortunately, local
specifiers are not allowed on PyPI. Thus, only the binaries compiled with the latest
CUDA version are uploaded. If you do not have a CUDA capable GPU, downloading this
is only a waste of bandwidth and disk capacity. If on the other hand simply don’t
have the latest CUDA driver installed, you can’t use any of the GPU features.To overcome this, PyTorch alos hostsallbinariesthemselves. To access them, you
still can usepip install, but have to use someadditional options:$pipinstalltorch==1.6.0+cpu-fhttps://download.pytorch.org/whl/torch_stable.htmlWhile this is certainly an improvement, it also has it downside: in addition to the
computation backend, the version has to be specified exactly. Without knowing what the
latest release is, it is impossible to install it as simple aspip install torchnormally would.At this point you might justifiably as: why don’t you just usecondaas PyTorch
recommends?$condainstallpytorchcpuonly-cpytorchThis should cover all cases, right? Well, almost. The above command is enough if you
just need PyTorch. Imagine the case of a package that depends on PyTorch, but
cannot be installed withcondasince it is hosted on PyPI? You can’t use the-foption since the package in question is not hosted by PyTorch. Thus, you now have to
manually track down (and resolve in the case of multiple packages) the PyTorch
distributions, install them in a first step and only install the actual package (and
all other dependencies) afterwards.If just want to usepip installlike you always did before without worrying about
any of the stuff above,pytorch-pip-shimwas made for you.How do I install it?Installingpytorch-pip-shimis as easy as$pipinstallpytorch-pip-shimSince it depends onpipand it might be upgraded during installation,Windows usersshould
install it with$python-mpipinstallpytorch-pip-shimHow do I use it?Afterpytorch-pip-shimis installed there is only a single step to insert the shim:$pytorch-pip-shiminsertAfter that you can usepipas you did before andpytorch-pip-shimhandles the
computation backend auto-detection for you in the background.If you want to remove the shim you can do so with$pytorch-pip-shimremoveYou can check its status with$pytorch-pip-shimstatusHow do I uninstall it?Uninstalling is as easy as$pipuninstallpytorch-pip-shimBy doing so,pytorch-pip-shimautomatically removes the shim if inserted.How do I configure it?Once inserted, you don’t need to configure anything. If you don’t want the computation
backend auto-detected but rather want to set it manuallypytorch-pip-shimadds two
CLI options topip install:--computation-backend<computation_backend>--cpuHow does it work?The authors ofpipdo not condonethe use ofpipinternals as they might
break without warning. As a results of this,piphas no capability for plugins to
hook into specific tasks. Thus, the only way to patchpips functionality is to
adapt its source in-place. Although this is really bad practice, it is unavoidable for
the goal of this package.pystiche-pip-shiminserts a shim into thepipmain file, which decorates the
main function. Everytime you callpip install, some aspects of the installation
process are patched:While searching for a download link for a PyTorch distribution,pytorch-pip-shimreplaces the default search index. This is equivalent to callingpip installwith
the-foption only for PyTorch distributions.While evaluating possible PyTorch installation candidates,pytorch-pip-shimculls
binaries not compatible with the available hardware.