GPU Passthroung for Gaming or Train models inside a virtual machine with GPU passthrough (WIP)
This project intends to create, modify and run virtual machines with GPU passthrough.
Based on the tutorial: PCI_passthrough_via_OVMF
Early development state project (WIP).
Only Arch-Linux is supported currently. Ubuntu support is in development state.
- Allow use of non root user launch the virtual machine.
- Add ubuntu support.
- Enable dhcp on the bridge network.
- Add looking glass host installation support.
Before you install/use this software:
- Must have arch-linux installed
- You need to enable the virtualization tecnologies on your bios. ("VT-d" or "AMD-Vi" or Virtualization technology)
- You need to enable the internal graphics and disable gpu startup on your bios.
- You need to enable IOMMU using kernel parameters (modifying your boot loader menu or it's configuration file).
Set intel_iommu=on (for intel processors) or amd_iommu=on (for amd ones).
You can add iommu=pt to prevent linux from touching devices that cant pass through.
More information here Edit kernel parameters - You need to have two monitor or a monitor with 2 inputs (for the virtual machine and the host).
- You need to isolate the GPUs you want to passthrough to prevent from the host OS using them. How to
pip3 install git+ssh://git@github.com/rodjjo/kvm-gpu-trainer.git --upgradevm-trainer --help
# or vm-trainer <command> --helpvm-trainer depman-install-build-tools
vm-trainer depman-install-git
vm-trainer depman-install-qemuFor more informations about scream click-here
vm-trainer depman-install-screamvm-trainer machine-create --name windows --cpus 4 --disk-size 200000 --memory 8192vm-trainer show-gpusvm-trainer machine-set-gpus --name windowsYou can press both CTRL keys to switch between the virtual machine and the host
vm-trainer machine-select-keyboard --name windowsvm-trainer machine-select-mouse --name windowsYou have to define the physical network adapter connected to the internet.
vm-trainer network-show-physical
# example of outputs:
# eth0
# enp6s0
vm-trainer settings-set-network-interface --name eth0vm-trainer machine-run-with-iso --name windows --iso location/to/my/original-windows10-disk.isoAfter you installed the operating system
vm-trainer machine-run --name windowsIf you have a vpn where qemu is running set the network to use the tap interface:
vm-trainer network-add-tap --target tun0Currently, this project create a bridge network with the ip 192.168.66.1 (you can change this).
You need to configure the network in the virtual machine to use static ip configuration:
IP: 192.168.66.2
Gateway: 192.168.66.1
DNS: 8.8.8.8
DHCP (automatic ip configuration) support is at the TODO list.
Set the IP address inside the Virtual Machine
sudo su
route delete default
ifconfig enp7s0 192.168.66.2 up
route add default gw 192.168.66.1 dev enp7s0
killall dnsmasq
dnsmasq --server=10.8.0.1 &
disown
resolvectl dns enp7s0 10.8.0.1
resolvectl default-route enp7s0 true
#vi /etc/resolv-conf.systemd
#nameserver 10.8.0.1
#systemctl restart systemd-resolved.servicesudo su
mkdir -p /mnt/data/shared/
mount -t 9p -o trans=virtio,version=9p2000.L hostshare /mnt/data/shared/Take a look at click-here
In order to plugin and play evdev:
https://github.com/aiberia/persistent-evdev/blob/master/README.md
OS: Arch Linux
Kernel: x86_64 Linux 5.8.9-arch2-1
Shell: zsh 5.8
Resolution: 1920x1080
DE: GNOME 3.36.4
Disk: 12T
CPU: Intel Core i5-3570 @ 4x 3.8GHz
GPU: GeForce GTX 1080
RAM: 24GB dual layer configuration: 8GB + 8GB and 4GB + 4GB