尧图网络 高端网站定制 · 原创设计
免费咨询热线
400-888-6620
免费获取方案
【Bug已解决】Pytorch CUDA error: no kernel image is available for execution on the device on RTX… 解决方案
【Bug已解决】Pytorch CUDA error: no kernel image is available for execution on the device on RTX 3090 with cuda 11.1 解决方案问题描述在使用 PyTorch 进行 GPU 训练时特别是在使用较新的 NVIDIA GPU如 RTX 3090、RTX 3080、A100 等 Ampere 架构显卡搭配特定版本的 CUDA 时开发者经常会遇到以下错误CUDA error: no kernel image is available for execution on the device这个错误通常在执行任何 CUDA 操作时出现例如tensor.to(cuda)、model.cuda()或任何 GPU 上的张量运算。错误的核心含义是PyTorch 编译的 CUDA 内核不包含当前 GPU 架构对应的二进制镜像PTX/SASS导致无法在当前 GPU 上执行。该问题在以下场景中尤为常见使用 RTX 30 系列Ampere, SM_86搭配旧版 PyTorch1.7 及以下使用 conda/pip 安装的 PyTorch 未包含对应架构的预编译内核CUDA 版本与 GPU 架构不匹配Docker 容器中使用了错误的 PyTorch 镜像从源码编译 PyTorch 时未指定正确的TORCH_CUDA_ARCH_LIST错误复现环境信息GPU: NVIDIA RTX 3090 (Ampere, Compute Capability 8.6)CUDA: 11.1PyTorch: 1.7.1 (通过 pip 安装)OS: Ubuntu 20.04复现代码import torch # 检查 CUDA 是否可用 print(fPyTorch version: {torch.__version__}) print(fCUDA available: {torch.cuda.is_available()}) print(fCUDA version: {torch.version.cuda}) # 尝试在 GPU 上创建张量 try: x torch.randn(3, 3).cuda() print(fTensor on GPU: {x}) except RuntimeError as e: print(fError: {e}) # CUDA error: no kernel image is available for execution on the device运行上述代码后输出如下PyTorch version: 1.7.1cu110 CUDA available: True CUDA version: 11.0 Error: CUDA error: no kernel image is available for execution on the device注意torch.cuda.is_available()返回True这说明 PyTorch 能检测到 GPU但由于缺少对应的内核镜像无法实际执行 CUDA 运算。进一步诊断import torch # 检查 GPU 信息 if torch.cuda.is_available(): print(fGPU: {torch.cuda.get_device_name(0)}) print(fCompute capability: {torch.cuda.get_device_capability(0)}) # RTX 3090 输出: (8, 6) 即 SM_86 # 检查 PyTorch 编译时支持的架构 major, minor torch.cuda.get_device_capability(0) arch_name fsm_{major}{minor} print(fRequired arch: {arch_name}) # 尝试简单运算 try: x torch.randn(10, 10, devicecuda) y x x.T print(fMatrix multiplication succeeded: {y.shape}) except RuntimeError as e: print(fOperation failed: {e})根因分析1. GPU 架构与 PyTorch 编译目标不匹配NVIDIA GPU 使用计算能力Compute Capability来标识架构版本每个版本对应一种 SMStreaming Multiprocessor架构GPU 系列架构计算能力SM 版本GTX 10xxPascal6.1sm_61RTX 20xxTuring7.5sm_75RTX 30xxAmpere8.6sm_86RTX 40xxAda8.9sm_89A100Ampere8.0sm_80H100Hopper9.0sm_90PyTorch 在编译时会为指定的架构生成对应的 CUDA 内核二进制文件。如果安装的 PyTorch 版本没有为sm_86RTX 3090编译内核就会报 no kernel image 错误。2. PyTorch 1.7 及以下版本的问题PyTorch 1.7 及更早版本默认不为sm_86编译内核因为 Ampere GPU 在这些版本发布时还未上市或刚上市。具体来说PyTorch 1.7 默认支持: sm_37, sm_50, sm_60, sm_70, sm_75PyTorch 1.8 开始支持: sm_80 (A100)PyTorch 1.9 开始完整支持: sm_86 (RTX 30 系列)PyTorch 1.12 支持: sm_89 (RTX 40 系列)3. CUDA 11.1 与 Ampere 的兼容性CUDA 11.0 引入了对sm_80A100的支持CUDA 11.1 增加了对sm_86RTX 30 系列的支持。但即使安装了 CUDA 11.1如果 PyTorch 是用 CUDA 11.0 编译的仍然缺少sm_86内核。4. pip/conda 安装的预编译版本通过pip install torch安装的 PyTorch 是预编译版本其包含的 SM 架构列表是固定的。如果预编译版本不包含你需要的架构就会出错。5. PTX 即时编译的局限性CUDA 内核可以以 PTX并行线程执行中间格式分发GPU 驱动可以在运行时将 PTX 编译为当前 GPU 的机器码。但不是所有内核都包含 PTX 版本即时编译会增加首次运行的延迟某些旧版驱动不支持新架构的 PTX 编译解决方案方案一升级 PyTorch 到支持 sm_86 的版本推荐这是最简单、最彻底的解决方案。升级到 PyTorch 1.9 或更高版本即可支持 RTX 30 系列。# 使用 pip 安装 PyTorch 1.9 with CUDA 11.1 pip install torch1.9.0cu111 torchvision0.10.0cu111 \ -f https://download.pytorch.org/whl/torch_stable.html # 或安装最新版本 pip install torch torchvision --extra-index-url \ https://download.pytorch.org/whl/cu118 # 使用 conda 安装 conda install pytorch torchvision torchaudio pytorch-cuda11.8 \ -c pytorch -c nvidia验证安装import torch print(fPyTorch version: {torch.__version__}) print(fCUDA version: {torch.version.cuda}) # 测试 GPU 运算 x torch.randn(100, 100, devicecuda) y x x.T print(fGPU computation successful: {y.shape}) print(fGPU: {torch.cuda.get_device_name(0)})方案二安装正确架构的预编译版本如果由于项目依赖限制无法升级到最新版本可以安装特定版本的正确构建。# PyTorch 1.8 支持 sm_80 (A100) 但不完全支持 sm_86 (RTX 30) # 需要安装 cu111 版本而非 cu110 版本 # 检查可用版本 pip install torch1.8.1cu111 -f https://download.pytorch.org/whl/torch_stable.html # PyTorch 1.9.0cu111 完整支持 RTX 30 系列 pip install torch1.9.0cu111 torchvision0.10.0cu111 \ -f https://download.pytorch.org/whl/torch_stable.html # PyTorch 1.10.1cu113 pip install torch1.10.1cu113 torchvision0.11.2cu113 \ -f https://download.pytorch.org/whl/torch_stable.html方案三从源码编译 PyTorch如果需要特定版本的 PyTorch 且预编译版本不支持你的 GPU可以从源码编译并指定架构。# 1. 安装依赖 sudo apt-get install -y \ build-essential cmake git libopenblas-dev liblapack-dev \ libjpeg-dev libpng-dev # 2. 克隆 PyTorch 源码 git clone --recursive https://github.com/pytorch/pytorch.git cd pytorch git checkout v1.9.0 # 选择需要的版本 git submodule sync git submodule update --init --recursive # 3. 设置环境变量 export CUDA_HOME/usr/local/cuda export PATH$CUDA_HOME/bin:$PATH export LD_LIBRARY_PATH$CUDA_HOME/lib64:$LD_LIBRARY_PATH # 关键: 指定目标 GPU 架构 # RTX 3090 sm_86, 也可以同时指定多个架构 export TORCH_CUDA_ARCH_LIST7.5;8.0;8.6 # 4. 编译 python setup.py install # 5. 验证 python -c import torch; print(torch.randn(10, devicecuda).sum())方案四使用 Docker 容器使用 NVIDIA 官方 PyTorch 镜像可以避免环境配置问题。# 拉取支持 RTX 30 系列的 PyTorch 镜像 docker pull pytorch/pytorch:1.9.0-cuda11.1-cudnn8-runtime # 运行容器需要 nvidia-docker docker run --gpus all -it \ pytorch/pytorch:1.9.0-cuda11.1-cudnn8-runtime \ python -c import torch; print(torch.randn(10, devicecuda).sum()) # 或使用 NGC 镜像更完整 docker pull nvcr.io/nvidia/pytorch:21.06-py3 docker run --gpus all -it nvcr.io/nvidia/pytorch:21.06-py3方案五使用 FORCE_CUDA 和 PTX 回退如果无法升级或编译可以尝试强制使用 PTX 即时编译。import os # 在导入 torch 之前设置 os.environ[CUDA_LAUNCH_BLOCKING] 1 import torch # 检查当前 PyTorch 支持的架构 # 这个信息在 PyTorch 编译时确定无法运行时改变 print(fPyTorch CUDA arch list: {torch.cuda.get_arch_list()}) # 如果列表中包含 sm_86 或 compute_86则支持 RTX 3090 # 如果只有 PTX (compute_xx)驱动会尝试即时编译完整修复代码 PyTorch CUDA 架构兼容性诊断与修复工具 检测 GPU 架构、PyTorch 支持情况并提供修复建议 import torch import sys import subprocess import platform from typing import List, Tuple, Optional class CudaCompatibilityChecker: CUDA 兼容性检查器 # GPU 架构信息表 ARCH_INFO { (6, 0): {name: Pascal, gpu: GTX 10xx (P100), min_cuda: 8.0}, (6, 1): {name: Pascal, gpu: GTX 10xx, min_cuda: 8.0}, (7, 0): {name: Volta, gpu: V100, min_cuda: 9.0}, (7, 5): {name: Turing, gpu: RTX 20xx / T4, min_cuda: 10.0}, (8, 0): {name: Ampere, gpu: A100, min_cuda: 11.0}, (8, 6): {name: Ampere, gpu: RTX 30xx, min_cuda: 11.1}, (8, 9): {name: Ada, gpu: RTX 40xx, min_cuda: 11.8}, (9, 0): {name: Hopper, gpu: H100, min_cuda: 12.0}, } # PyTorch 版本与架构支持 PYTORCH_ARCH_SUPPORT { 1.7: [sm_37, sm_50, sm_60, sm_70, sm_75], 1.8: [sm_37, sm_50, sm_60, sm_70, sm_75, sm_80], 1.9: [sm_37, sm_50, sm_60, sm_70, sm_75, sm_80, sm_86], 1.10: [sm_37, sm_50, sm_60, sm_70, sm_75, sm_80, sm_86], 1.11: [sm_37, sm_50, sm_60, sm_70, sm_75, sm_80, sm_86], 1.12: [sm_37, sm_50, sm_60, sm_70, sm_75, sm_80, sm_86, sm_89], 2.0: [sm_37, sm_50, sm_60, sm_70, sm_75, sm_80, sm_86, sm_89, sm_90], } def __init__(self): self.results {} def check_all(self) - dict: 运行完整检查 print( * 60) print(PyTorch CUDA 兼容性诊断) print( * 60) self._check_system() self._check_pytorch() self._check_gpu() self._check_compatibility() self._test_gpu_operation() return self.results def _check_system(self): 检查系统信息 print(\n--- 系统信息 ---) print(fOS: {platform.system()} {platform.release()}) print(fPython: {sys.version}) # 检查 NVIDIA 驱动 try: result subprocess.run( [nvidia-smi, --query-gpudriver_version,name,compute_cap, --formatcsv,noheader], capture_outputTrue, textTrue ) if result.returncode 0: print(fNVIDIA driver: {result.stdout.strip()}) self.results[nvidia_smi] result.stdout.strip() except FileNotFoundError: print(Warning: nvidia-smi not found) def _check_pytorch(self): 检查 PyTorch 信息 print(\n--- PyTorch 信息 ---) print(fPyTorch version: {torch.__version__}) print(fCUDA version (compiled): {torch.version.cuda}) print(fcuDNN version: {torch.backends.cudnn.version()}) # 获取编译时的架构列表 arch_list torch.cuda.get_arch_list() if torch.cuda.is_available() else [] print(fCompiled CUDA arch list: {arch_list}) self.results[pytorch_version] torch.__version__ self.results[cuda_version] torch.version.cuda self.results[arch_list] arch_list def _check_gpu(self): 检查 GPU 信息 print(\n--- GPU 信息 ---) if not torch.cuda.is_available(): print(CUDA not available!) self.results[gpu_available] False return self.results[gpu_available] True num_gpus torch.cuda.device_count() print(fGPU count: {num_gpus}) for i in range(num_gpus): name torch.cuda.get_device_name(i) cap torch.cuda.get_device_capability(i) arch_name fsm_{cap[0]}{cap[1]} print(fGPU {i}: {name}) print(f Compute capability: {cap[0]}.{cap[1]} ({arch_name})) arch_info self.ARCH_INFO.get(cap, {}) if arch_info: print(f Architecture: {arch_info.get(name, Unknown)}) print(f GPU series: {arch_info.get(gpu, Unknown)}) print(f Min CUDA required: {arch_info.get(min_cuda, Unknown)}) self.results[fgpu_{i}] { name: name, capability: cap, arch_name: arch_name } def _check_compatibility(self): 检查兼容性 print(\n--- 兼容性分析 ---) if not self.results.get(gpu_available): print(无法检查兼容性GPU 不可用) return gpu_cap self.results.get(gpu_0, {}).get(capability) if not gpu_cap: return required_arch fsm_{gpu_cap[0]}{gpu_cap[1]} arch_list self.results.get(arch_list, []) # 检查是否直接支持 direct_support required_arch in arch_list # 检查 PTX 回退 ptx_arch fcompute_{gpu_cap[0]}{gpu_cap[1]} ptx_support ptx_arch in arch_list # 检查更低版本的 PTX可能通过 JIT 编译 ptx_fallback any( a.startswith(compute_) and int(a.split(_)[1]) gpu_cap[0] * 10 gpu_cap[1] for a in arch_list ) if direct_support: print(f[OK] PyTorch 直接支持 {required_arch}) self.results[compatible] True elif ptx_support: print(f[WARN] PyTorch 通过 PTX 即时编译支持 {required_arch}) print( 首次运行会有额外延迟) self.results[compatible] True else: print(f[ERROR] PyTorch 不支持 {required_arch}) print(f 编译的架构列表: {arch_list}) self.results[compatible] False self._provide_fix_suggestions(gpu_cap) def _provide_fix_suggestions(self, gpu_cap): 提供修复建议 print(\n--- 修复建议 ---) required_arch fsm_{gpu_cap[0]}{gpu_cap[1]} pt_version torch.__version__.split()[0] major_minor ..join(pt_version.split(.)[:2]) # 找到支持当前架构的最低 PyTorch 版本 min_pt_version None for ver, archs in sorted(self.PYTORCH_ARCH_SUPPORT.items()): if required_arch in archs: min_pt_version ver break if min_pt_version: print(f1. 升级 PyTorch 到 {min_pt_version} 或更高版本:) cuda_ver self.results.get(cuda_version, 11.8) cuda_short cuda_ver.replace(., )[:3] if cuda_ver else 118 print(f pip install torch{min_pt_version} --extra-index-url fhttps://download.pytorch.org/whl/cu{cuda_short}) print(f2. 从源码编译 PyTorch:) print(f export TORCH_CUDA_ARCH_LIST\{gpu_cap[0]}.{gpu_cap[1]}\) print(f python setup.py install) print(f3. 使用 Docker:) print(f docker pull pytorch/pytorch:{min_pt_version or 2.0}-cuda11.8-cudnn8-runtime) def _test_gpu_operation(self): 测试 GPU 运算 print(\n--- GPU 运算测试 ---) if not self.results.get(gpu_available): return tests [ (张量创建, lambda: torch.randn(100, 100, devicecuda)), (矩阵乘法, lambda: torch.randn(50, 50, devicecuda) torch.randn(50, 50, devicecuda)), (卷积运算, lambda: torch.nn.functional.conv2d( torch.randn(1, 3, 32, 32, devicecuda), torch.randn(16, 3, 3, 3, devicecuda), padding1)), ( reductions, lambda: torch.randn(1000, devicecuda).sum()), ] all_passed True for name, test_fn in tests: try: result test_fn() torch.cuda.synchronize() print(f [PASS] {name}) except RuntimeError as e: print(f [FAIL] {name}: {e}) all_passed False if all_passed: print(\n所有 GPU 运算测试通过) else: print(\n部分 GPU 运算失败需要修复。) self.results[all_tests_passed] all_passed def quick_fix(): 快速修复脚本 print( * 60) print(PyTorch CUDA 快速修复) print( * 60) import torch if not torch.cuda.is_available(): print(CUDA 不可用请检查 NVIDIA 驱动安装) return gpu_name torch.cuda.get_device_name(0) gpu_cap torch.cuda.get_device_capability(0) arch_list torch.cuda.get_arch_list() required fsm_{gpu_cap[0]}{gpu_cap[1]} print(fGPU: {gpu_name}) print(fCompute capability: {gpu_cap[0]}.{gpu_cap[1]} ({required})) print(fPyTorch version: {torch.__version__}) print(fCUDA version: {torch.version.cuda}) print(fArch list: {arch_list}) if required in arch_list: print(f\n[OK] {required} is directly supported) else: print(f\n[ISSUE] {required} is NOT in arch list) print(\nRecommended fix:) print( pip install torch --upgrade --extra-index-url https://download.pytorch.org/whl/cu118) # 测试 try: x torch.randn(100, 100, devicecuda) y x x.T torch.cuda.synchronize() print(f\n[Test] GPU computation: PASS (result shape: {y.shape})) except RuntimeError as e: print(f\n[Test] GPU computation: FAIL ({e})) if __name__ __main__: checker CudaCompatibilityChecker() results checker.check_all() print(\n * 60) print(快速修复检查) print( * 60) quick_fix()常见陷阱与注意事项1. torch.cuda.is_available() 返回 True 但无法运算这是一个常见的误导。is_available()只检查驱动和 CUDA 运行时是否存在不检查内核兼容性。即使返回True也可能因为缺少内核镜像而无法执行运算。2. CUDA 版本 vs 驱动版本CUDA 有两个版本概念CUDA Driver 版本由nvidia-smi显示是 NVIDIA 驱动支持的 CUDA 版本CUDA Runtime 版本由torch.version.cuda显示是 PyTorch 编译时使用的 CUDA 版本Runtime 版本必须 Driver 版本。如果 Driver 版本太旧需要更新 NVIDIA 驱动。# 查看驱动支持的 CUDA 版本 nvidia-smi | grep CUDA Version # 查看 PyTorch 使用的 CUDA 版本 python -c import torch; print(torch.version.cuda)3. conda 安装的 CUDA 冲突使用 conda 安装 PyTorch 时conda 会安装自己的 CUDA 运行时。如果系统也安装了 CUDA可能产生冲突。建议使用 conda 安装时让 conda 管理所有 CUDA 依赖不要混合使用 conda 安装的 CUDA 和系统安装的 CUDA4. 多 GPU 环境的架构差异如果服务器上有多种架构的 GPU如同时有 RTX 2080 Ti 和 RTX 3090需要确保 PyTorch 编译时包含了所有架构export TORCH_CUDA_ARCH_LIST7.5;8.65. PyTorch Nightly 版本如果需要最新的架构支持但不想等正式发布可以使用 nightly 版本pip install --pre torch torchvision --extra-index-url \ https://download.pytorch.org/whl/nightly/cu1186. CUDA Forward CompatibilityNVIDIA 提供 CUDA Forward Compatibility 包允许在旧驱动上运行新 CUDA 版本。但这只适用于数据中心 GPUTesla/A100不适用于消费级 GPUGeForce。7. 验证安装的正确方法安装后使用以下命令全面验证import torch # 基本检查 print(fPyTorch: {torch.__version__}) print(fCUDA: {torch.version.cuda}) print(fcuDNN: {torch.backends.cudnn.version()}) print(fGPU: {torch.cuda.get_device_name(0)}) print(fCapability: {torch.cuda.get_device_capability(0)}) print(fArch list: {torch.cuda.get_arch_list()}) # 运算测试 x torch.randn(1000, 1000, devicecuda) y torch.randn(1000, 1000, devicecuda) z x y # 矩阵乘法 torch.cuda.synchronize() print(fMatrix mul: {z.shape}, sum{z.sum().item():.4f}) # 卷积测试 conv torch.nn.Conv2d(3, 64, 3, padding1).cuda() img torch.randn(1, 3, 224, 224, devicecuda) out conv(img) torch.cuda.synchronize() print(fConv2d: {out.shape}) # 反向传播测试 loss out.sum() loss.backward() torch.cuda.synchronize() print(Backward pass: OK) print(\n所有测试通过)总结CUDA error: no kernel image is available for execution on the device的根本原因是 PyTorch 编译时未包含当前 GPU 架构对应的 CUDA 内核。对于 RTX 3090SM_86需要 PyTorch 1.9 和 CUDA 11.1。解决步骤诊断使用torch.cuda.get_device_capability()和torch.cuda.get_arch_list()确认 GPU 架构和 PyTorch 支持的架构列表。升级最简单的解决方案是升级 PyTorch 到 1.9支持 sm_86或更高版本使用正确的 CUDA 版本后缀。源码编译如果必须使用特定版本从源码编译并设置TORCH_CUDA_ARCH_LIST包含你的 GPU 架构。Docker使用官方 PyTorch Docker 镜像可以避免环境配置问题。验证安装后运行矩阵乘法、卷积和反向传播测试确保 GPU 运算正常。核心原则确保 PyTorch 编译时包含的 CUDA 架构列表覆盖你的 GPU 架构。这是解决 no kernel image 错误的关键。
RELATED

相关推荐

TCN时间序列预测实战:Python实现外汇走势建模,对比LSTM

TCN时间序列预测实战:Python实现外汇走势建模,对比LSTM

简介:面向数据科学家和机器学习爱好者,这份项目实例完整演示了如何用Python构建时间卷积神经网络(TCN)进行时间序列预测,尤其针对外汇市场的未来数值走向建模。内容覆盖TCN基于因果卷积与膨胀卷积的工作原理、相对RNN缓…

📅 2026/10/17 16:30:02
RAG优化实战:从检索到生成的系统性调优指南

RAG优化实战:从检索到生成的系统性调优指南

做知识库问答的朋友应该都有同感:模型能力再强,只要检索链路掉链子,回答就会前言不搭后语。RAG(检索增强生成)本身不是什么新鲜概念,但真正把它调到好用、稳定、让人敢上线,中间隔着一大堆细节。…

📅 2026/10/17 16:25:02
Tkinter标签cursor参数的常用值:TaoToken统一Key下桌面GUI鼠标指针配置速查

Tkinter标签cursor参数的常用值:TaoToken统一Key下桌面GUI鼠标指针配置速查

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

📅 2026/10/17 16:25:02
MORE NEWS

更多资讯

📰

LongCat-Flash-Lite-Sparse-8bit 4-bit/6-bit/8-bit怎么选?附Mac内存需求对照与量化选型指南

【免费下载链接】LongCat-Flash-Lite-Sparse-8bit 项目地址: https://ai.gitcode.com/hf_mirrors/mlx-community/LongCat-Flash-Lite-Sparse-8bit 点击查看 免费下载 LongCat-Flash-Lite-Sparse-8bit 是美团 69B-A3B MoE 模型 LongCat-Flash-Lite-Sparse 的 MLX 8-…

📰

Spring Boot整合Redis:缓存、序列化与分布式锁实战

做后端开发,Redis基本是绕不开的组件。我第一次被它圈粉,是因为有个内部系统每天高峰期被同一个查询接口打成筛子,数据库CPU飙到99%,加了Redis缓存之后,QPS翻了几倍还不止,数据库负载直接掉到20%。后来我在…

📰

企业级智能体难在工程:OpenClaw部署与治理全解析

1. 先破除一个误区:企业级智能体之难,难在工程而非模型很多团队拿到 OpenClaw 的第一反应,是急着调模型、叠 Prompt、压测对话效果。我见过不少项目,Demo 演示时全屋惊叹,结果一到内网部署、连上真实业务系统&#xff…

📰

Windows平台XDMA驱动开发与PCIe高速传输工程实践

1. 项目概述1.1 为什么突然聊起 XDMA做 FPGA 数据采集和高性能传输的同仁,最近一定绕不开 XDMA 这个词。尤其是当你手里的 PCIe 项目从 Linux 环境迁到 Windows 平台,或者需要在 Windows 上做视频采集、高速 ADC 数据回放、NVMe 协议桥接这类应用时&…

📰

Kimi K2 + Claude Code 接入 3 个神级开源 MCP,相当丝滑

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

📰

Keras-bert模型部署实战:用Flask封装文本分类预测服务

模型预测跑通只是第一步,把模型交到别人手里才算真上线。这篇Keras入门第七篇,我用Flask把Keras-bert训练出来的文本分类模型包成一个HTTP预测服务,让业务方直接通过接口调用,而不是把模型文件丢过去让人家自己跑脚本。适合已经训…

TODAY

今日更新

THIS WEEK

本周精选

THIS MONTH

本月热门

读完文章,想聊聊您的网站?

告诉我们您的行业与需求,资深顾问一对一梳理方案与报价,全程免费。

📞 💬