2

I am creating a Python package that depends on PyTorch. PyTorch's installation command is as follows (from https://pytorch.org/):

pip3 install torch==1.8.2+cu102 torchvision==0.9.2+cu102 torchaudio==0.8.2 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html

Question 1: How should I prepare setup.py?

I read this Equivalent for `--find-links` in `setup.py` where it says we could add the link into dependency_links list, but this is no longer supported since 2019.

Question 2: How to programatically decide which version to install? (CPU, GPU, CUDA version)

The command above is for a GPU-enabled machine with CUDA 10.2. But if the machine doesn't have GPU, one would use:

pip3 install torch==1.8.2+cpu torchvision==0.9.2+cpu torchaudio==0.8.2 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html

Is it possible for my package's setup.py to automatically identify the user's system and modify the install_requires list accordingly?

Michael
  • 1,834
  • 2
  • 20
  • 33
  • 1
    Ask only 1 question at a time. -- First one is answered in the question you linked and that I answered. -- For the second one: it is not possible as far as I know. Basically I think I answered this already in the comments of my answer: document it clearly so that your users know what to do. There is nothing much you can do. Unless the situation has improved on Pytorch's side in the meantime. – sinoroc Feb 24 '22 at 14:40
  • Does this answer your question? [Equivalent for \`--find-links\` in \`setup.py\`](https://stackoverflow.com/questions/57689387/equivalent-for-find-links-in-setup-py) – sinoroc Feb 24 '22 at 14:40
  • This should answer your question: [https://stackoverflow.com/questions/66738473/installing-pytorch-with-cuda-in-setup-py](https://stackoverflow.com/questions/66738473/installing-pytorch-with-cuda-in-setup-py) – repié Apr 15 '22 at 08:36

0 Answers0