Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
NVIDIA A100 demo
# Show system
lscpu
lspci -nnn
nvidia-smi
# Enable MIG
nvidia-smi -mig 1
# List GPU instance profiles
nvidia-smi mig -lgip
# Create some GPU instances
nvidia-smi mig -cgi 2g.10gb,1g.5gb,1g.5gb
# List resulting GPU instances
nvidia-smi mig -lgi
# List compute instance profiles
nvidia-smi mig -lcip
# Create some compute instances
nvidia-smi mig -cci 1g.5gb -gi 7
nvidia-smi mig -cci 1g.5gb -gi 13
nvidia-smi mig -cci 1c.2g.10gb,1c.2g.10gb -gi 5
# Look at the result
nvidia-smi
nvidia-smi -L
# Pass full GPU (no MIG)
lxc init images:ubuntu/20.04 foo -c nvidia.runtime=true
lxc config device add foo gpu1 gpu gputype=physical pci=07:00.0
lxc start foo
lxc exec foo bash
nvidia-smi
# Pass one MIG
lxc init images:ubuntu/20.04 bar -c nvidia.runtime=true
lxc config device add bar gpu0 gpu gputype=mig mig.uuid=MIG-eabf689a-9e86-5d58-90b0-b4ad686fd897 pci=07:00.0
lxc start bar
lxc exec bar bash
nvidia-smi
# Add another MIG
lxc stop bar
lxc config device add bar gpu1 gpu gputype=mig mig.uuid=MIG-eabf689a-9e86-5d58-90b0-b4ad686fd897 pci=07:00.0
lxc exec bar bash
nvidia-smi
# Disable MIG
lxc delete -f foo bar
nvidia-smi -mig 0
nvidia-smi
# Disclaimer about vGPU, GRID and licensing
# Enable SR-IOV
/usr/lib/nvidia/sriov-manage -e ALL
# Look at mdev
lxc info --resources
# Start a VM
lxc init images:ubuntu/20.04 foo --vm -c limits.cpu=4 -c limits.memory=8GiB -c security.secureboot=false
lxc config device add foo gpu1 gpu gputype=mdev mdev=nvidia-471 pci=07:00.0
lxc start foo
# Start another VM
lxc init images:ubuntu/20.04 bar --vm -c limits.cpu=4 -c limits.memory=8GiB -c security.secureboot=false
lxc config device add bar gpu1 gpu gputype=mdev mdev=nvidia-471 pci=07:00.0
lxc start bar
# Install some drivers
lxc exec foo bash
apt-get update
apt-get install build-essential wget pciutils linux-headers-virtual
wget http://canonical-lxd.stgraber.org/nvidia/v14.0/nvidia-guest.deb
apt-get install /root/nvidia-guest.deb
nvidia-smi
# Look on the host
nvidia-smi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment