[Python] Can't manage to run Pytorch with GPU

Discussão em 'Python' iniciado por Stack, Fevereiro 9, 2025.

  1. Stack

    Stack Membro Participativo

    everyone! I have a problem - I am trying to make pytorch run on GPU, but I got no success.

    I innstalled CUDA version 12.6, downloaded CUDA 12.6 compatible pytorch, reinstalled all things a few times, but python still outputs that no CUDA found. What else could I do? My specs - RTX 3060, 24 GB RAM, AMD Ryzen 7. Windows 11 machine I am trying to run this code:

    import torch

    print(f"Is CUDA supported by this system?{torch.cuda.is_available()}")
    print(f"CUDA version: {torch.version.cuda}")

    # Storing ID of current CUDA device
    cuda_id = torch.cuda.current_device()
    print(f"ID of current CUDA device:{torch.cuda.current_device()}")

    print(f"Name of current CUDA device:{torch.cuda.get_device_name(cuda_id)}")`


    And keep getting this response:

    C:\\Users\\Valen\\PycharmProjects\\godhelpme.venv\\Scripts\\python.exe "D:\\Programming shit\\godhelpme\\torchtest.py"
    Traceback (most recent call last):
    File "D:\\Programming shit\\godhelpme\\torchtest.py", line 7, in \<module\>
    cuda_id = torch.cuda.current_device()
    File "C:\\Users\\Valen\\PycharmProjects\\godhelpme.venv\\Lib\\site-packages\\torch\\cuda\__init_\_.py", line 971, in current_device
    _lazy_init()
    \~\~\~\~\~\~\~\~\~\~^^
    File "C:\\Users\\Valen\\PycharmProjects\\godhelpme.venv\\Lib\\site-packages\\torch\\cuda_init_.py", line 310, in \_lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")
    AssertionError: Torch not compiled with CUDA enabled
    Is CUDA supported by this system?False
    CUDA version: None

    Process finished with exit code 1

    Continue reading...

Compartilhe esta Página