AssertionError: Torch not compiled with CUDA enabled
时间: 2023-10-13 20:27:09 浏览: 205
解决AssertionError Torch not compiled with CUDA enabled.docx
This error occurs when you try to use CUDA functionality in PyTorch, but PyTorch was not compiled with CUDA support. To fix this error, you need to reinstall PyTorch with CUDA enabled.
Here are the steps to install PyTorch with CUDA enabled:
1. Check if your system has a compatible NVIDIA GPU by running the following command in the terminal:
```
lspci | grep -i nvidia
```
If you see the output of this command with the details of your NVIDIA GPU, then your system is compatible.
2. Install the CUDA Toolkit by following the instructions on the NVIDIA website. Make sure to install a version that is compatible with your GPU and your operating system.
3. Install PyTorch with CUDA support by running the following command in the terminal:
```
pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/cu<version>/torch_stable.html
```
Replace `<version>` with the version of CUDA that you installed in step 2. For example, if you installed CUDA 11.1, use `cu111` in the command.
After installing PyTorch with CUDA support, you should be able to use CUDA functionality without any errors.
阅读全文