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