# Python 3.x
pip3 install torch torchvision
#for cuba
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116
The best way is going to pytorch official website and coping the code
presented since it gives the best version according to your systems
requirements
NOTE: Python 3.9 users will need to add '-c=conda-forge' for installationconda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch