Can't to install PyTorch for CUDA 12.4

Hi Team,

I know my topic looks somehow similar to this one Trying (and failing) to install PyTorch for CUDA 12.0
I tried what is written there and for some reasons it’s not work for me.

Laptop environment setup

  • Windows 11 with the latest updates

  • Installed CUDA Toolkit cuda_12.4.1_551.78_windows.exe

  • Installed cuDNN 9.0.0 for CUDA 12

Anaconda Environment configuration
conda create --name gpt_env python=3.7
conda activate gpt_env
pip install tensorflow
pip show tensorflow
pip install torch torchvision torchaudio --extra-index-url url is hidden as formum denied to publish more then 2 urls (pytorch/whl/cu121)
pip install transformers
conda install -c conda-forge jupyterlab
conda install -c conda-forge pandas
conda install -c conda-forge seaborn
conda install -c conda-forge matplotlib

conda install -c conda-forge jupyterlab_widgets  
conda install -c conda-forge yipywidgets 
conda install -c conda-forge scikit-learn

Issue
when I check if PyTorch is available in my Jupiter lab notebook i have False

print(torch.cuda.is_available()) ---> False

If I’m trying to install PyTorch as was suggested in topic above i have following error
(gpt_env2) PS C:\Users\NoName> pip install [url hidden]/whl/nightly/cu121/torch-2.1.0.dev20230811%2Bcu121-cp311-cp311-win_amd64.whl
ERROR: torch-2.1.0.dev20230811+cu121-cp311-cp311-win_amd64.whl is not a supported wheel on this platform.

I have to mention that i have Intell based laptop with NVIDIA GPU, so i tried below, and doesn’t work as well
(gpt_env) PS C:\Users\NoName> pip install [url hidden]/whl/nightly/cu121/torch-2.1.0.dev20230811%2Bcu121-cp311-cp311-win_x86_64.whl
ERROR: torch-2.1.0.dev20230811+cu121-cp311-cp311-win_x86_64.whl is not a supported wheel on this platform.

Could you please help me resolve this issue and make PyTorch compiled to work use GPU in the first place

Appreciate your help in advance,
Best regards,
Maks.

Colleagues,

problem solved. The issue was simple I wasn’t read the PyTorch site good enough. Especcialy that part that generates for anaconda command. As of Apr-12-2024, this banner showed that minimum required version of python is >= 3.8, and i was setup my environment for python 3.7. so 2 commands fixed everything:

  1. conda create --name my_env python=3.10
  2. conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia

Then as suggested by ptrblck in Torch not compiled with CUDA enabled - #22 by ptrblck
Run several commands to check if all good:

1. Python
2. >>> import torch
3. >>> torch.version.cuda
'11.8'
4. >>> torch.__version__
'2.0.0'
5. >>> x = torch.randn(1).cuda()
6. >>> x
tensor([1.7900], device='cuda:0')

NOTE: Make sure you have installed CUDA 12.1 along with appropriate version of CuDNN

4 Likes

thank you. so strange, pytorch-cuda 12.4 forces cpu…

1 Like

:pray: :pray: :pray: :pray:
still works thank you so much

thank you for this hint!! I’ve struggled with pytorch-cuda=12.4 for a whole day and always got a cpu version. Now I just changed it to 12.1 then everything got fine… what a nightmare…

1 Like

Mine also keeps only using cpu what’s the fix?

I don’t understand this solution.

Is Cuda 12.4 just not compatible?

Hello! Here’s the situation: the NVIDIA Studio driver 565.90 (GTX 1650 Ti) is installed, and PyTorch version 12.4 is installed. When running the command import torch print(torch.cuda.is_available()), it returns False. Everything is directed to the CPU.
What should I do? When checking the version, it shows 2.5.1+cpu. I need PyTorch to direct tasks to the GPU and work with CUDA built into the graphics card driver. Where is the bottleneck, and how can I work around it? Thank you. Heeeeelp (Windows 10 64) It’s possible that version 12.4 doesn’t support the driver or, conversely, doesn’t support the GPU. Should I install the CUDA Toolkit? If so, which version? Or should I set something in the environment variables? (I’m writing my script in Python 3.10, VS Code) install version 12.1 … result : [Running] python -u “d:\TRAN v1\CUda.py”
PyTorch is using CPU.
Tensor is allocated on: cpu
2.5.1+cpu

You have installed the CPU-only binary so install a PyTorch binary with CUDA support.

I installed by this link: pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 vesion 12.1 the same result :frowning:

Could you please tell me which version supports CUDA? Is it available for download, or do I need to install the CUDA Toolkit?

I faced the same problem of trying to install pytorch-cuda=12.4 but it kept installing the cpu version. Installing on a fresh environment worked in my case.

You don’t need to install a CUDA toolkit as the PyTorch binaries ship with their own CUDA runtime dependencies.
Select any CUDA version from the install matrix on pytorch.org, copy/paste the command into your terminal, and execute it.

For some reason I get cuda not available with pytorch 2.5.1, while it works with 2.2.1.

I had some problems with pip and used --no-cache-dir option

but not much experience with conda