Skip to content

Instantly share code, notes, and snippets.

@ksuperman
Forked from khfeng/CUDA in LXC via LXD
Created March 11, 2017 05:20
Show Gist options
  • Save ksuperman/9e2b649925e034b743893d56956a3070 to your computer and use it in GitHub Desktop.
Save ksuperman/9e2b649925e034b743893d56956a3070 to your computer and use it in GitHub Desktop.
# Suppose we already have LXD, and already add the default image repo as images:
# 1. Start a new Trusty LXC container
host:~$ lxc launch images:ubuntu/trusty/amd64 cuda-trusty
# 2. Download and install CUDA on *both* host & LXC container, from https://developer.nvidia.com/cuda-downloads
# Note that host and container have to have *exactly* the same driver version
# 3. Add necessary Nvidia devices to LXC container
host:~$ lxc config device add cuda-trusty nvidia0 unix-char path=/dev/nvidia0
host:~$ lxc config device add cuda-trusty nvidiactl unix-char path=/dev/nvidiactl
host:~$ lxc config device add cuda-trusty nvidia-uvm unix-char path=/dev/nvidia-uvm
# Now your container should have CUDA capability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment