NVidia CUDA inside a LXD container?

(Using Ubuntu 16.04 64bit) Trying to implement “NVidia CUDA inside a LXD container” as per https://stgraber.org/2017/03/21/cuda-in-lxd/

“Note that for this to work, you’ll need LXD 2.5 or higher.”

To satisfy the LXD 2.5 requirement I followed the guide at https://linuxcontainers.org/lxd/getting-started-cli/ which instructs for Ubuntu 16.40 LTS to run the following “apt install -t xenial-backports lxd lxd-client”

Not sure if this was due to my setup, but that backports command resulted in something about it being invalid. Turns out that xenial-backports needs to be enabled and configured for manual installs as per https://help.ubuntu.com/community/UbuntuBackports#Enabling_Backports_Manually (I did it a little differently, created new files in sources.list.d & preferences.d)

After that sudo apt-get update and then the command “apt install -t xenial-backports lxd lxd-client” works.

HOWEVER, following is what didn’t quite work. The guide for “NVidia CUDA inside a LXD container” states that LXD 2.5+ is needed and I did all the above to get the latest features release… but “sudo lxd --version” returns version 2.20

Are there any guides on how to install LXD 2.5+ ? I thought I was on the right track but that didn’t work out.

I may have gotten mixed up and will verify. I was comparing the .5 to the .2, which might not be correct. Maybe I should have been looking at .5 vs .20… in decimal the .5 is greater but maybe in versioning the .20 is greater. Will verify and post an update regarding that.

Yeah, turns out I got the versioning mixed up. Version 2.20 got access to the GPU within containers using the guide at https://stgraber.org/2017/03/21/cuda-in-lxd/

Feel free to delete this thread or maybe leave it up in case anyone else makes the same mistake.