How to install pytorch CPU in requirements.txt?

We can install pytorch’s CPU version via pip install torch==2.1.1 --index-url

How can I add this to requirements.txt so I can install CPU version of it using pip install -r requirements.txt?

This is more Python than PyTorch, but you can either use --index-url (but this is global, so a bit tricky for requirements.txt) or give specific packages (whl archives) with @.

Best regards


Here are the details:

1 Like

Thanks a lot, torch @ format worked well!