AssertionError: Torch not compiled with CUDA enabled
时间: 2023-10-12 17:11:08 浏览: 101
解决pytorch报错:AssertionError: Invalid device id的问题
This error occurs when PyTorch is not compiled with CUDA enabled, which is necessary for running neural network models on GPUs.
To fix this error, you need to reinstall PyTorch with CUDA support. You can do this by specifying the CUDA version during installation. For example, if you have CUDA 10.2 installed, you can use the following command to install PyTorch with CUDA support:
```
pip install torch==1.7.0+cu102 -f https://download.pytorch.org/whl/cu102/torch_stable.html
```
Make sure to replace the CUDA version with the one installed on your system. Once PyTorch is installed with CUDA support, you can use it to train and run neural network models on GPUs.
阅读全文