AssertionError: My CUDA Wont’t Load


AssertionError: Torch not compiled with CUDA enabled

You’ve probably ran across this multiple times.. and if you have any hair left, its ok now. You can stop banging your head on the table. Here’s what’s going on:

You’re attempting to use your NVIDIA graphics card but it’s not installed.

Wait! But you installed it with the Windows package right? Yes… that was first installations, but what about second installations?

When you are using virtual environments (ie. Conda):
you must install cudatoolkit every time.

The order is important as well… install cudatoolkit and THEN reinstall pytorch from this link. You must get it in the right order as pyTorch depends on CUDA being installed and accessible.

  1. conda activate <env>
  2. conda config --append channels nvidia
    • *this is a one time step
    • * it gives conda access to nvidia’s package repository
  3. conda install -c nvidia cudatoolkit==11.8.0 (don’t install 12.0)
  4. go to https://pytorch.org/get-started/locally/ and copy the pip installation
  5. pip3 install --force-reinstall torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

Leave a Reply

Your email address will not be published. Required fields are marked *