0

I am trying to use Torch to find my GPU for machine learning/training.
Right now, my code is using the CPU for training, which will take a long time with the large amounts of data I have.

import torch
print(torch.cuda.is_available())
print(torch.cuda.get_device_name(0))

I'm using the code above to check for the GPU, and I get this error:

AssertionError: Torch not compiled with CUDA enabled

When I asked some of the AIs, they said that the latest Torch version with Python 3.13 doesn't have support for it, but I haven't seen anyone come across this, and other people can use it.

6
  • 1
    did you install torch with cuda Commented Oct 5 at 3:41
  • yes using pip install torch torchvision torchaudio --index-url download.pytorch.org/whl/cu121 and on pytorches website and documentation there is nothing about cuda torch being unavailable with python 3.13 Commented Oct 5 at 3:45
  • 1
    The version of PyTorch you say you installed and the version your Python environment finds are clearly not the same. You probably have two different versions installed Commented Oct 5 at 9:31
  • always put full error message (traceback) because there are other useful information. Commented Oct 5 at 12:17
  • this behavior may suggest that you have two Pythons installed and you could install torch with cuda for one Python but you test it with different Python. Do you use IDE to run code? It may uses own Python. If you install it in console then you may use python -m pip install ... and later test it python script.py. In code you may also use print( sys.executable ) to get /full/path/to/python and also use this to install /full/path/to/python -m pip install ... Commented Oct 5 at 12:20

2 Answers 2

2

Using Version 118 download.pytorch.org/whl/cu118 works with Python 3.13 — unfortunately, no other version does, which was honestly quite confusing. However, when using Python 3.11, it was compatible with both 118 and 121.

Sign up to request clarification or add additional context in comments.

Comments

0

Highly recommend downgrading their Python version from 3.13 to either 3.12 or 3.11. Hope this resolves your problem

2 Comments

Thank you — that worked! However, it was a bit of a hassle. Afterwards, I found out from Kraigola’s link that someone had used 118 for version 3.13, which also worked, so I ended up reverting back to 3.13 after making this discovery.
I suspect that this answer might have just worked coincidentally. As pointed out by @talonmies in the comments on the question, it's possible the torch+cuda install occurred for a different Python installation than was running for OP. I suggest editing this answer to incorporate why downgrading would be helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.