惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
WordPress大学
WordPress大学
博客园 - 【当耐特】
Engineering at Meta
Engineering at Meta
IT之家
IT之家
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
美团技术团队
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
H
Help Net Security
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
博客园_首页
A
About on SuperTechFans
MongoDB | Blog
MongoDB | Blog
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
B
Blog
The Register - Security
The Register - Security
I
InfoQ
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
Last Week in AI
Last Week in AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
有赞技术团队
有赞技术团队
Stack Overflow Blog
Stack Overflow Blog
Jina AI
Jina AI
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News - Newest:
Hacker News - Newest: "LLM"
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
W
WeLiveSecurity
Latest news
Latest news
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
博客园 - 叶小钗
L
Lohrmann on Cybersecurity
博客园 - Franky
Recent Commits to openclaw:main
Recent Commits to openclaw:main
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

Jiajun的技术笔记

你好,2026! TiDB 源码阅读(六):TiDB Coprocessor 源码解析 性能优化的核心思想 TiDB 源码阅读(五):索引 TiDB 源码阅读(四):AST、逻辑计划、物理计划 CockroachDB Serverless Architecture podman 无故退出 Cursor Control-L (CTRL-L) Keyboard Shortcuts in Terminal Replace docker with podman Using xmonad with xfce4 A RC script for freebsd frpc 自己动手写一个k8s controller AI 会取代你的(编程)岗位吗? 自建DERP服务器提升Tailscale连接速度(使用Nginx转发) 自动升级Docker容器 再读《程序员修炼之道-从小工到专家》 让浏览器下载文件 再读《软件随想录》/《黑客与画家》/《软技能》 HTTP 压力测试中的 Coordinated Omission 2的补码 编程语言中的 context 是什么? flutter macOS 构建出错 Flatpak 使用小记 Golang CAS 操作是怎么实现的 PostgreSQL 当MQ来使用 Clash 结合 工作VPN 的网络设计 使用 PostgreSQL 搭建 JuiceFS PostgreSQL 配置优化和日志分析 有GitHub Copilot?那就可以搭建你的ChatGPT4服务 窗口函数的使用(以PG为例) 读《为什么学生不喜欢上学》 OpenAI Prompt Engineering 摘录和总结 读《打造真正的新产品》 VueJS 总结 Linux 自动挂载 alist 提供的webdav FreeBSD 使用 vm-bhyve 安装Debian虚拟机 FreeBSD 和 Linux 网卡聚合实现提速 GPT 帮我搞定了时区转换问题 长任务系统如何处理? macOS/Linux 编译 InputLeap 使用开源软KVM - synergy-core 解决 macOS 终端hostname一直变化问题 PromQL 备忘 读《格鲁夫给经理人的第一课》 读《打开心智》 为什么要把复杂的联表操作拆成多个单表查询? 红包系统的设计 MySQL Index Condition Pushdown Optimization Go mod 简明教程 OpenWRT 使用 Android/iOS USB 网络 搭建旁路由 Golang gRPC 错误处理 编写可维护的单元测试代码 OAuth 2 详解(六):Authorization Code Flow with PKCE OAuth 2 详解(五):Device Authorization Flow OAuth 2 详解(三):Resource Owner Password Credentials Grant OAuth 2 详解(四):Client Credentials Flow OAuth 2 详解(二):Implict Grant Flow OAuth 2 详解(一):简介及 Authorization Code 模式 ElasticSearch 学习笔记 三种git流程以及发版模型 错误处理实践 权限模型(RBAC/ABAC) OIDC(OpenID Connect) 简介 任务队列简介 PostgreSQL 操作笔记 使用Drone CI构建CI/CD系统 Golang migrate 做数据库变更管理 使用PostgreSQL做搜索引擎 Nginx 源码阅读(三): 连接池、内存池 Nginx 源码阅读(二): 请求处理 Nginx 源码阅读(一): 启动流程 Go 泛型简明教程 KVM 显卡穿透给 Windows 使用 HTTP Router 处理 Telegram Bot 按钮回调 使用反射(reflect)对结构体赋值 GIN 是如何绑定参数的 你好 2022(2021 年终总结) 用Go导入大型CSV到PostgreSQL 使用 OpenWRT 搭建软路由 使用软KVM切换器 barrier 共享键鼠 SQL 防注入及原理 使用 gomock 测试 Go 代码 gevent不是黑魔法(二): gevent 实现 gevent不是黑魔法(一): greenlet 实现 用 entgo 替代 gorm 应用内使用crontab不是那么方便 单测时要不要 mock 数据库? Sentry 自建指南 用selenium完成自动化任务 用闲置的安卓手机做垃圾电话短信过滤 推荐三个时间管理工具 一次事故反思 当JS遇到uint64:JS整数溢出问题 SQLite3 存储以及ACID原理 Redis源码阅读:pub/sub实现 Redis源码阅读:zset实现 Redis源码阅读:bitmap 位图的运算 Redis源码阅读:set是怎么做交并集运算的? Redis源码阅读:list实现(ziplist, quicklist)
KVM 共享 Intel 集成显卡
Jiajun Huang · 2023-11-05 · via Jiajun的技术笔记

我比较喜欢折腾虚拟化,最近在折腾的就是这个:把宿主机的 Intel 集成显卡 给 Windows 虚拟机使用。Intel 平台做这个事情非常 方便,因为官方有 Intel GVT-g 项目,就是用来把宿主机生成多个虚拟 GPU 给虚拟机用的。

共享集成显卡

  1. 首先我们需要安装 virt-manager
  2. 编辑宿主机 /etc/default/grub 文件,在 GRUB_CMDLINE_LINUX 中,添加 i915.enable_gvt=1 i915.enable_fbc=0
  3. 重新生成GRUB 配置 sudo update-grub
  4. 编辑 /etc/modules-load.d/kvm-gvt-g.conf 配置文件,内容为:

    kvmgt
    vfio-iommu-type1
    mdev
    
  5. 宿主机安装Mesa库 apt-get install mesa-utils

  6. 重启宿主机,执行 lspci | grep VGA,看看输出是否有 00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 630 (Mobile) (rev 02) 类似这么一行

  7. 进入文件夹 cd /sys/bus/pci/devices/0000\:00:02.0

  8. 执行 ls -l mdev_supported_types/ 看是否有输出,每一个都是一种GPU的类型,数字越大,显存越小,可以通过执行 cat /sys/devices/pci0000\:00/0000\:00\:02.0/mdev_supported_types/<类型>/description 查看每种类型的描述

  9. 选择一个类型,生成一个uuid,创建一个虚拟GPU

    # uuidgen
    945248c6-8d80-44a3-9a19-d85e22b19a7f
    
    # echo 945248c6-8d80-44a3-9a19-d85e22b19a7f | tee mdev_supported_types/i915-GVTg_V5_4/create
    
  10. 上述配置每次重启都会丢失,为了让宿主机每次启动都生成上述GPU,编辑一个systemd文件 /etc/systemd/system/setup-gvt.service

    [Unit]
    Description=Setup GVT
    
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/bash -c 'echo 945248c6-8d80-44a3-9a19-d85e22b19a7f > /sys/devices/pci0000:00/0000:00:02.0/mdev_supported_types/i915-GVTg_V5_4/create'
    
    [Install]
    WantedBy=multi-user.target
    
  11. 安装Windows 10虚拟机,记得安装 virtio 驱动,这个我在 KVM 显卡穿透给 Windows 讲过,此处不赘述,也可以看参考文档中第一篇

  12. virsh 编辑虚拟机 xml

    • 第一行 <domain type='kvm'> 改成 <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
    • 找到 <graphics ...> 那一行,改成

      <graphics type='spice'>
      <listen type='none'/>
      <gl enable='yes' rendernode='/dev/dri/by-path/pci-0000:00:02.0-render'/>
      </graphics>
      
    • 找到 xml 中的 video 那一块,原来的内容可能是

      <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
      </video>
      

    改成

    <video>
        <model type='none'/>
    </video>
    
  13. 编辑文件,在 <video> 后面,增加

    <hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci' display='on'>
    <source>
    <address uuid='945248c6-8d80-44a3-9a19-d85e22b19a7f'/>
    </source>
    <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
    </hostdev>
    
  14. 启动虚拟机

Windows RDP 远程桌面配置优化

  1. Windows-R 输入 gpedit.msc,找到 Computer Configuration > Policies > Administrative Template > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Connections
    • “RDP Transfer Protocols” 设置为 True,下面选择 “Use both UDP and TCP”
  2. Computer Configuration > Policies > Administrative Template > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Remote Session Enviorment 编辑
    • Use hardware graphics adapters for all Remote Desktop Services Sessions = Enabled
    • Prioritize H.264/AVC 444 graphics mode for Remote Desktop Connections = Enabled
    • Configure H.264/AVC Hardware encoding for Remote Desktop Connections = Enabled, Set “Prefer AVC hardware encoding” to “Always attempt”
    • Configure compression for Remote FX data = Enabled, Set RDP compression algorithem: “Do not use an RDP compression algorithm”
    • Configure image quality for RemoteFX Adaptive Graphics = Enabled, Set Image Quality to “High” (lossless seemed too brutal over WAN connections.)
    • Enable RemoteFX encoding for RemoteFX clients designed for Windows Server 2008R2 SP1 = Enabled.
  3. Computer Configuration > Policies&amp;gt;Administrative Template > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Remote Session Enviorment > Remote FX for Windows Server 2008R2

    • Configure Remote FX = Enabled
    • Optimize visual experience when using Remote FX = Enabled
    • Set Screen capture rate (frames per second) = Highest (best quality)
    • Set Screen Image Quality = Highest (best quality)
    • Optimize visual experience for remote desktop sessions = Enabled
    • Set Visual Experience = Rich Multimedia
  4. Windows-R 输入 regedit,找到 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations]

    • 新建 Dword(32) 类型,名为 DWMFRAMEINTERVAL,值为 0000000f
  5. 重启


参考资料:


相关文章