Skip to content

Instantly share code, notes, and snippets.

@khfeng
Last active October 16, 2017 05:21
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save khfeng/1a7fbb75f3baa0eabafb to your computer and use it in GitHub Desktop.
Save khfeng/1a7fbb75f3baa0eabafb 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