解决NVIDIA RTX 50系显卡(5080)与PyTorch的兼容性问题

Qwen3-32B-Chat 私有部署镜像 | RTX4090D 24G 显存 CUDA12.4 优化版

本镜像基于 RTX 4090D 24GB 显存 + CUDA 12.4 + 驱动 550.90.07 深度优化,内置完整运行环境与 Qwen3-32B 模型依赖,开箱即用。

ubuntu 24.04系统,安装了anaconda和spyder, 安装了vscode, 安装了pytorch,显卡为NVIDIA RTX 5080
测试pytorch以及GPU:

import torch
import time

def benchmark_test():
    # 设置测试参数
    size = 1000
    iterations = 100
    
    print(f"=== 性能测试 ({iterations} 次 {size}x{size} 矩阵乘法) ===")
    
    # CPU测试
    device_cpu = torch.device('cpu')
    a = torch.randn(size, size, device=device_cpu)
    b = torch.randn(size, size, device=device_cpu)
    
    start_time = time.time()
    for _ in range(iterations):
        c = torch.mm(a, b)
    cpu_time = time.time() - start_time
    print(f"CPU 平均时间: {cpu_time/iterations:.4f} 秒")
    
    # GPU测试(如果可用)
    if torch.cuda.is_available():
        device_gpu = torch.device('cuda')
        a_gpu = torch.randn(size, size, device=device_gpu)
        b_gpu = torch.randn(size, size, device=device_gpu)
        
        # 预热GPU
        for _ in range(10):
            torch.mm(a_gpu, b_gpu)
        torch.cuda.synchronize()
        
        start_time = time.time()
        for _ in range(iterations):
            c_gpu = torch.mm(a_gpu, b_gpu)
        torch.cuda.synchronize()
        gpu_time = time.time() - start_time
        print(f"GPU 平均时间: {gpu_time/iterations:.4f} 秒")
        print(f"GPU 加速比: {cpu_time/gpu_time:.2f}x")

benchmark_test()

报错:

%runfile '/home/user/Documents/seg_models/attenunet/未命名2.py' --wdir
=== 性能测试 (100 次 1000x1000 矩阵乘法) ===
CPU 平均时间: 0.0020 秒
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/Documents/seg_models/attenunet/未命名2.py:49
     46         print(f"GPU 平均时间: {gpu_time/iterations:.4f} 秒")
     47         print(f"GPU 加速比: {cpu_time/gpu_time:.2f}x")
---> 49 benchmark_test()

File ~/Documents/seg_models/attenunet/未命名2.py:33, in benchmark_test()
     31 if torch.cuda.is_available():
     32     device_gpu = torch.device('cuda')
---> 33     a_gpu = torch.randn(size, size, device=device_gpu)
     34     b_gpu = torch.randn(size, size, device=device_gpu)
     36     # 预热GPU

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
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.

原因:

错误 “CUDA error: no kernel image is available for execution on the device” 通常发生在 CUDA 版本、GPU 架构和 PyTorch 版本不兼容时。
系统 CUDA 是 12.0,而 PyTorch 是为 12.1 编译的.

解决办法:
首先利用conda activate 进入环境:
然后执行:

# 1. 卸载任何旧的PyTorch安装 (如果之前安装过)
pip uninstall torch torchvision torchaudio -y
pip cache purge # 清理pip缓存

# 2. 安装支持CUDA 12.8的PyTorch Nightly Build
# 注意:--pre 标志用于安装预发布版本 (如 nightly build)
pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128

解决方案来源:
聚合AI平台
Claude 、Gemini、GPT 等大模型聚合ai平台

显卡算力来源:
显卡云算力平台

成功解决:
图片

您可能感兴趣的与本文相关的镜像

Qwen3-32B-Chat 私有部署镜像 | RTX4090D 24G 显存 CUDA12.4 优化版

Qwen3-32B-Chat 私有部署镜像 | RTX4090D 24G 显存 CUDA12.4 优化版

Qwen
文本生成
Qwen3

本镜像基于 RTX 4090D 24GB 显存 + CUDA 12.4 + 驱动 550.90.07 深度优化,内置完整运行环境与 Qwen3-32B 模型依赖,开箱即用。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

裤裤兔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值