1、3090ti,3080ti,4090等英伟达设备,安装pytorch,需要注意,要满足下面条件
cuda11.1 <= pytorch-cuda --version <= 机器上安装的 cuda --version
2、验证
import torch
torch.cuda.is_available()
# 返回True 接着用下列代码进一步测试
torch.zeros(1).cuda()
如果版本安装有问题,可能会有如下错误信息:
1、
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.
2、
lib/python3.7/site-packages/torch/cuda/__init__.py:145: UserWarning:
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/
warnings.warn(incompatible_device_warn.format(device_name, capability, " ".join(arch_list), device_name))
Traceback (most recent call last):
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.