How to install gpu version of pyroch-lightning?

Sorry about this easy question, but I am just trying to install lightning with

conda create --name some_new_envs
activate some_new_envs
pip install lightning

From the docs it seems like by default with this installation, lightning will install pytorch and detect available GPU automatically. But for me its not the case…
I also tried first install gpu version of pytorch with (I am using a lower version of pytorch)

conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=11.0 -c pytorch

then install the lightning with

pip install lightning

This time when installing the lightning, it will automatically uninstall pytorch==1.7 and install pytorch==2.0, nevertheless, it still can not detect my GPU…

Any suggestions please? :frowning:

Hey @seabro917
If you want to install pytorch with conda, you need to specify the cudatoolkit to install the cuda version, otherwise it installs the cpu version. I suggest you go to the pytorch.org website, select the settings for your platform and then copy-paste the command to install torch. You will find the install commands for older versions of pytorch in the “previous versions” section here: Previous PyTorch Versions | PyTorch

For example, pytorch 1.7.0 with cuda 11, the command for linux would be:

conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=11.0 -c pytorch

This time when installing the lightning, it will automatically uninstall pytorch==1.7 and install pytorch==2.0

This is because the newest version of lightning no longer supports the very old pytorch 1.7. Here is a table that shows which version of lightning you can use with which version of pytorch:
https://lightning.ai/docs/pytorch/stable/versioning.html#compatibility-matrix

This shows that you can use at maximum lightning 1.5 together with torch 1.7. For this case, you would install like this:

pip install pytorch_lightning==1.5

Let me know if that helps.

Hi @awaelchli !

Thanks for the help!
Yes, I understand that I have to specify a cudatookit for installing the GPU version of torch (as I mentioned in my question description). And you are right, I guess the problem is with the compatibility issue between different versions of lightning and torch, I will try as you suggested!

Thanks a lot! :slight_smile:

BTW. during replying to you, I just recalled why I used torch==1.7 → this old version. I was trying to install latest GPU version of torch, and I tried as you said, go to their website and just copy paste corresponding command, it did not work for me :frowning:. Not sure whether this is because I have CUDA 12.1 while in the command for installing latest GPU version of torch has only pytorch-cuda=11.7 and pytorch-cuda=11.8.

I’m facing the very same issue.
I tried installing lightning version 1.5 but nothing changes. It keeps uninstalling the current pytorch and installing the newest version.