出现如下报错:
NVIDIA GeForce RTX 3090 with CUDA capability sm_86 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70.
If you want to use the NVIDIA GeForce RTX 3090 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/
......RuntimeError: CUDA error: no kernel image is available for execution on the device
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
上面报错的大概意思是说 pytorch的版本的CUDA的版本不匹配!
Python 3.7.16 (default, Jan 17 2023, 22:20:44)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.__version__
'1.11.0+cu102'
执行python后发现自己的cu10.2可能太老了,所以直接去这个网站下载对应版本的torch:
网站:download.pytorch.org/whl/torch_stable.html
然后下载torch-1.12.0+cu113-cp37-cp37m-linux_x86_64.whl
然后使用命令安装:
pip install torch-1.12.0+cu113-cp37-cp37m-linux_x86_64.whl
最后再次执行python:
Python 3.7.16 (default, Jan 17 2023, 22:20:44)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.__version__
'1.12.0+cu113'
OK! 搞定了哈哈哈哈哈!