Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install pytorch with CUDA support with pip in Visual Studio

Tags:

python

pytorch

I am trying to install torch with CUDA enabled in Visual Studio environment. I right clicked on Python Environments in Solution Explorer, uninstalled the existing version of Torch that is not compiled with CUDA and tried to run this pip command from the official Pytorch website. The command is:

pip3 install torch==1.10.0+cu102 torchvision==0.11.1+cu102 torchaudio===0.10.0+cu102 -f https://download.pytorch.org/whl/cu102/torch_stable.html

Visual Studio reports this error Looking in links: https://download.pytorch.org/whl/cu102/torch_stable.html ERROR: Could not find a version that satisfies the requirement pip3 (from versions: none) ERROR: No matching distribution found for pip3.

I have seen similar questions asked on this site but some are circumventing on Conda while others did have unclear answers which were not accepted so I was in doubt whether to follow the answers or not. I have a very important project I need to present and I can't do that unless I install torch with cuda enabled, Please Help me and Thanks.


1 Answers

I followed the main instructions for installing on pytorch's site but still failed to have success. For my setup this resulted in pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117.

I had to add --upgrade --force-reinstall which finally fixed the problem.

like image 84
mbuc91 Avatar answered Dec 07 '25 20:12

mbuc91



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!