It has been solved to debug the Transformer network on the ubuntu virtual machine, throwing an exception RuntimeError: CUDA error: no kernel image is available for execution on the device The correct solution, the personal test is effective, and the corresponding relationship between each version of pytorch and cuda version is attached at the end of the article! ! !
Article Directory
Error report
A friend came to private message me when he encountered a problem, and wanted to use the ubuntu virtual machine to debug the Transformer network, but an error occurred (at that time, his heart was cold for a moment, and he came to me for help, and then successfully helped him solve it, by the way Record it and hope it can help more friends who encounter this bug and will not solve it), the error code is as follows:
Computer configuration :
- GPU 3080 computing power 8.6
- CUDA 11.1
- CUDNN 8.2.0
- conda 4.9.2
- python 3.8.5
The content of the error message is as follows :
RuntimeError: CUDA error: no kernel image is available for execution on the device
error translation
The translation of the error message content is as follows :
Runtime Error: CUDA Error: No executable kernel image on device
Error reason
Reason for the error :
The torch version is 1.9.1, but due to the installation of the timm package, torch was reinstalled, the original version was overwritten, and now it becomes 1.8.1, so the torch environment was destroyed, and there was a conflict between package versions, resulting in cuda The version is 11.1, which is not compatible with the torch version.
Friends, you can solve it according to the following method! ! !
Solution
The cuda accessories are not compatible with the current version of pytorch, uninstall all and restart
1. The first step is to uninstall pytorch
pip uninstall pytorch
2. Go to the official website to copy the installation instructions and install them with conda. Official instructions:
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
Among them, torchvision torchaudio does not need to be installed if it is not in the CV direction; -c means downloading from the official website, which is extremely slow, do not use this, use a mirror image; cudatoolkit=11.3 means the cuda accessory version, it is this incompatibility that causes an error, replace it with your own version number .
The installation instructions under the final CUDA 11.1 version are simplified to:conda install pytorch cudatoolkit=11.1 pytorch
Correspondence between pytorch versions and cuda versions
Official website link : https://pytorch.org/get-started/previous-versions/
Note : Does the lower version of pytorch support a higher version of cuda; a higher version of pytorch is generally compatible with a lower version of cuda. For example: you need pytorch 1.7.0, then cuda can only be 11.0 and below. The officially recommended cuda versions are 10.2 and 11.3, which support most pytorch versions.
PyTorch version | CUDA environment |
---|---|
0.4.1、1.2.0、1.4.0、1.5.0(1)、1.6.0、1.7.0(1) | 9.2 |
1.2.0、1.1.0、1.0.0(1) | 10.0 |
1.4.0、1.5.0(1)、1.6.0、1.7.0(1) | 10.1 |
1.5.0(1)、1.6.0、1.7.0(1)、1.8.0(1)、1.9.0、1.10.0 | 10.2 |
1.7.0(1) | 11.0 |
1.8.0(1)、1.9.0、1.10.0 | 11.1 |
1.8.0(1)、1.9.0、1.10.0 | 11.3 |
The above is the solution to the cause of this error. Welcome to leave a message in the comment area to discuss whether it can be solved.If it is useful, please like and collect the article. Thank you for your support. The blogger has the motivation to keep recording the problems encountered.!!!
Thousands of full-stack VIP Q&A group to contact bloggers to help solve errors
Due to the limited time and energy of bloggers, there are too many private messages every day, and there is no way for every fan to reply in time, so reply to VIP fans first, and you can enter the thousand-person full stack by subscribing to the time-limited 9.9 paid column "100 Days Mastering Python from Getting Started to Employment" VIP answering group, get priority answering opportunities (code guidance, remote service), free prostitution 80G learning materials spree, column subscription address: https://blog.csdn.net/yuan2019035055/category_11466020.html
-
Advantages :The author gives priority to answering opportunities (code guidance, remote service), and many bigwigs in the group can hold together to keep warm (big factory internal promotion opportunities). This column is a complete set of teaching specially prepared for students with zero foundation and those who need advanced improvement , From 0 to 100, continue to advance and deepen, and there will be practical projects in the follow-up, so you can easily deal with interviews!
-
Column benefits :Resume guidance, internal referral for recruitment, weekly delivery of physical books, 80G full-stack learning videos, 300 IT e-books: Python, Java, front-end, big data, database, algorithm, crawler, data analysis, machine learning, interview question bank, etc.
-
Note : If you want to get a timely reply, communicate and learn with the big guys, after subscribing to the column, private message the blogger to enter the VIP Q&A group with thousands of people