├── .gitignore ├── _export.sh ├── LICENSE ├── check.sh ├── _container_build.sh └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.bz2 2 | last.* 3 | coreos_developer_container.bin.* 4 | nvidia_installers/ 5 | pkg/ 6 | -------------------------------------------------------------------------------- /_export.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | ARTIFACT_DIR=$1 6 | VERSION=$2 7 | COMBINED_VERSION=$3 8 | 9 | TOOLS="nvidia-debugdump nvidia-cuda-mps-control nvidia-xconfig nvidia-modprobe nvidia-smi nvidia-cuda-mps-server 10 | nvidia-persistenced nvidia-settings" 11 | 12 | # Create archives with no paths 13 | tar -C ${ARTIFACT_DIR} -cvj $(basename -a ${ARTIFACT_DIR}/*.so.*) > libraries-${VERSION}.tar.bz2 14 | tar -C ${ARTIFACT_DIR} -cvj ${TOOLS} > tools-${VERSION}.tar.bz2 15 | tar -C ${ARTIFACT_DIR}/kernel -cvj $(basename -a ${ARTIFACT_DIR}/kernel/*.ko) > modules-${COMBINED_VERSION}.tar.bz2 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2016 Clarifai, Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | -------------------------------------------------------------------------------- /check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Check for NVIDIA driver updates 4 | # 5 | 6 | DRIVER=${1:-367.27} 7 | 8 | TRACKS="${2:-alpha beta stable}" 9 | for track in ${TRACKS} 10 | do 11 | # Can't use $(< because it prints errors for a missing file! 12 | last=$(cat last.${track} 2>/dev/null) 13 | 14 | # Grab the most recent directory 15 | curl -s https://${track}.release.core-os.net/amd64-usr/ | 16 | grep -oE '' | grep -o '[0-9\.]*' | 17 | sort -n | tail -1 | while read v; do 18 | # Use sort -V version comparison 19 | if [ "${last}" != "$(/bin/echo -e ${v}\\n${last} | sort -rV | head -1)" ] 20 | then 21 | # We rely on the previous sorting to build the most recent version last 22 | bash -x ./build.sh ${DRIVER} ${track} ${v} && echo ${v} > last.${track} 23 | fi 24 | done 25 | done 26 | exit 27 | -------------------------------------------------------------------------------- /_container_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Default: use binary packages instead of building everything from source 4 | EMERGE_SOURCE_FLAGS=gK 5 | while :; do 6 | case $1 in 7 | --emerge-sources) 8 | EMERGE_SOURCE_FLAGS= 9 | ;; 10 | *) 11 | break 12 | esac 13 | shift 14 | done 15 | 16 | 17 | VERSION=$1 18 | echo Building ${VERSION} 19 | 20 | function finish { 21 | cat /nvidia_installers/NVIDIA-Linux-x86_64-${VERSION}/nvidia-installer.log 22 | } 23 | 24 | set -e 25 | trap finish exit 26 | 27 | emerge-gitclone 28 | . /usr/share/coreos/release 29 | git -C /var/lib/portage/coreos-overlay checkout build-${COREOS_RELEASE_VERSION%%.*} 30 | emerge -${EMERGE_SOURCE_FLAGS}q --jobs 4 --load-average 4 coreos-sources 31 | 32 | cd /usr/src/linux 33 | cp /lib/modules/*-coreos*/build/.config .config 34 | 35 | make olddefconfig 36 | make modules_prepare 37 | 38 | cd /nvidia_installers/NVIDIA-Linux-x86_64-${VERSION} 39 | ./nvidia-installer -s -n --kernel-source-path=/usr/src/linux \ 40 | --no-check-for-alternate-installs --no-opengl-files \ 41 | --kernel-install-path=${PWD} --log-file-name=${PWD}/nvidia-installer.log 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # coreos-nvidia 2 | Simplified building of NVIDIA drivers for CoreOS Linux 3 | 4 | This set of scripts will cross-build a given version of NVIDIA drivers for a 5 | given version of CoreOS. It does so by running the build inside the developer 6 | container image associated with the OS version, i.e. using the same compiler 7 | toolchain and kernel configuration used by the system. The scripts can be 8 | started from a machine running _any_ kind of Linux distribution: it 9 | **doesn't** have to be CoreOS. 10 | 11 | ## Requirements: 12 | 13 | - any Linux distribution 14 | - `systemd-nspawn` (tested on version 229, there might be issues with <= 225) 15 | - `sudo`, to run `systemd-nspawn` 16 | - `curl` 17 | - `bzip2` and `bunzip2` 18 | - about 4GB of scratch disk space, most of it taken by the uncompressed 19 | developer image 20 | 21 | ## Usage: 22 | 23 | build.sh [--keep] DRIVER_VERSION CHANNEL COREOS_VERSION 24 | 25 | e.g. 26 | 27 | `./build.sh 367.27 alpha 1097.0.0` 28 | 29 | The scripts will download both the official NVIDIA archive and the CoreOS 30 | developer images, caching them afterwards. If you pass the `--keep` flag, the 31 | temporary container used for building will be preserved after the run; this is 32 | helpful for debugging purposes. The scripts will then create three archives: 33 | 34 | ``` 35 | libraries-[DRIVER_VERSION].tar.bz2 36 | tools-[DRIVER_VERSION].tar.bz2 37 | modules-[COREOS_VERSION]-[DRIVER_VERSION].tar.bz2 38 | ``` 39 | 40 | Getting the libraries, tools and modules onto final systems, as well as creating 41 | device nodes under `/dev/`, depends a lot on their particular provisioning 42 | (cloud-config, Ansible, etc.), so it is left as an exercise to the reader. A few 43 | tips: 44 | 45 | - on CoreOS, `/lib64/`, `/usr/lib64/` and co. all reside on a read-only 46 | filesystem. You might need to create a new directory elsewhere and its location 47 | listed in a file under `/etc/ld.so.conf.d/` 48 | - depending on your intepretation of [FHS 49 | specifications](http://refspecs.linuxfoundation.org/fhs.shtml), directories 50 | under `/opt/` or `/srv/` might be an option. `/opt/bin/` is already in users' 51 | search path, the `PATH` variable. 52 | 53 | ## Automating driver builds for new OS releases 54 | 55 | Another script, check.sh, can be run as a cron 56 | job to automatically build drivers for new versions of CoreOS as they get 57 | released. 58 | 59 | ### Usage 60 | 61 | `./check.sh DRIVER_VERSION COREOS_CHANNELS` 62 | 63 | where `COREOS_CHANNELS` defaults to `"alpha beta stable"`. Example: 64 | 65 | `./check.sh 367.27 "beta stable"` 66 | 67 | The first time, it will build drivers for the most recent release of each given 68 | channel. Upon subsequent invocations, it will build only newer releases it 69 | hasn't built before — and still only the most recent one per channel. The script 70 | expects to live in a writable directory which is persisted across runs and 71 | includes the other scripts. 72 | --------------------------------------------------------------------------------