├── README.md └── Dockerfile /README.md: -------------------------------------------------------------------------------- 1 | # CoreOS-Nvidia 2 | This is a Dockerfile that builds a container with nvidia GPU drivers. Once built running the container in privileged mode will install the kernel module. 3 | 4 | It should be built on a machine running the same CoreOS (actually 681.x.x) version as the target machine (the one with the Nvidia card installed), if not the target machine itself. Of course the container can only be run on a machine with Nvidia hardware installed. 5 | 6 | Note: It does not install CUDA. 7 | 8 | ### To Build 9 | 10 | docker build -t coreos-nvidia github.com/hookenz/coreos-nvidia 11 | 12 | ### To Run 13 | 14 | docker run --privileged=true -t coreos-nvidia 15 | 16 | To confirm the module is loaded. 17 | 18 | lsmod | grep -i nvidia 19 | 20 | #### Notes 21 | 22 | There may be a batter base image, and some post build cleanup that could be done to make the container smaller. 23 | 24 | Currently the build uses `uname -r` to detect the running kernel version. There maybe be a better way to do this that offers more flexibility. 25 | 26 | Also, the driver version is hard coded (`352.21`), automatically finding the latest driver would be a nice improvement. 27 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:15.04 2 | MAINTAINER Joshua Kolden 3 | 4 | # Setup environment 5 | RUN apt-get -y update && apt-get -y install gcc-4.8 \ 6 | wget git make dpkg-dev module-init-tools && \ 7 | mkdir -p /usr/src/kernels && \ 8 | mkdir -p /opt/nvidia && \ 9 | apt-get autoremove && apt-get clean 10 | 11 | # Ensure we're using gcc 4.8 12 | RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10 13 | 14 | # Downloading early so we fail early if we can't get the key ingredient 15 | RUN wget -P /opt/nvidia http://us.download.nvidia.com/XFree86/Linux-x86_64/352.21/NVIDIA-Linux-x86_64-352.21.run 16 | 17 | # Download kernel source and prepare modules 18 | WORKDIR /usr/src/kernels 19 | RUN git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux 20 | WORKDIR linux 21 | RUN git checkout -b stable v`uname -r` && zcat /proc/config.gz > .config && make modules_prepare 22 | RUN sed -i -e "s/`uname -r`+/`uname -r`/" include/generated/utsrelease.h # In case a '+' was added 23 | 24 | # Nvidia drivers setup 25 | WORKDIR /opt/nvidia 26 | RUN echo "./NVIDIA-Linux-x86_64-352.21.run -q -a -n -s --kernel-source-path=/usr/src/kernels/linux/ && modprobe nvidia" >> install_kernel_module && \ 27 | chmod +x NVIDIA-Linux-x86_64-352.21.run install_kernel_module 28 | 29 | CMD ["/opt/nvidia/install_kernel_module"] 30 | --------------------------------------------------------------------------------