This tool allows you to cross-compile a specific NVIDIA GPU driver runfile for a specific Container-Optimized OS (COS) version and board. It outputs the compiled kernel modules, the input runfile, and an updated gpu_driver_versions.bin file, which can then be uploaded to a custom GCS bucket and installed on COS instances.
Consolidating the compilation logic into Go ensures a robust and reproducible build environment that matches the official COS build process.
my-custom-cos-artifacts)..run file of the NVIDIA driver version you want to compile (e.g., NVIDIA-Linux-x86_64-580.126.20.run).Build the compilation tool from the repository root:
go build -o compile_gpu_driver src/cmd/compile_gpu_driver/main.go
Run the tool, specifying the local runfile, target COS version (build number), target board, and output directory:
./compile_gpu_driver \ -runfile /path/to/NVIDIA-Linux-x86_64-580.126.20.run \ -cos-version 19506.120.64 \ -cos-board lakitu \ -out-dir ./output
The tool will:
cos-tools GCS bucket.gpu_driver_versions.bin config for that COS version../output directory:nvidia-drivers-580.126.20.tgz (the compiled modules package)gpu_driver_versions.bin (updated configuration)NVIDIA-Linux-x86_64-580.126.20.run (copy of the input runfile)Upload the generated files to your GCS bucket. While not strictly required, it is highly recommended to use a structured GCS path (prefix) to organize your artifacts (e.g., by COS version and board):
gs://<your-bucket>/<gcs-prefix>/
For example, you can use the standard 19506.120.64/lakitu structure, or any other custom path of your choice:
export BUCKET="my-custom-cos-artifacts" export PREFIX="19506.120.64/lakitu" # Or any custom prefix of your choice (e.g., "custom-drivers/580") export DRIVER_VER="580.126.20" # Upload the compiled driver package gsutil cp ./output/nvidia-drivers-${DRIVER_VER}.tgz gs://${BUCKET}/${PREFIX}/ # Upload the updated versions configuration gsutil cp ./output/gpu_driver_versions.bin gs://${BUCKET}/${PREFIX}/ # Upload the input runfile gsutil cp ./output/NVIDIA-Linux-x86_64-${DRIVER_VER}.run gs://${BUCKET}/${PREFIX}/
Because your custom compiled GPU driver is not signed by Google's private key, the standard COS kernel will refuse to load the kernel modules by default due to strict module signature enforcement and Integrity Measurement Architecture (IMA) policies.
To successfully install and load your custom driver, you must configure your COS VM with the following security changes:
module.sig_enforce=0 and ima_appraise=off.To install your custom compiled driver on a COS instance, you can use the standard cos-extensions install gpu command. Any arguments passed after -- are forwarded verbatim to the underlying cos-gpu-installer container.
This allows you to instruct the installer to download artifacts from your custom GCS bucket and prefix instead of the official public bucket.
cos-extensions with your GCS bucket and the corresponding prefix flags passed after -- (make sure the prefix matches the GCS path you uploaded files to in Step 2):export BUCKET="my-custom-cos-artifacts" export PREFIX="19506.120.64/lakitu" # Must match the prefix used in Step 2 export DRIVER_VER="580.126.20" sudo cos-extensions install gpu -- \ -version="${DRIVER_VER}" \ -gcs-download-bucket="${BUCKET}" \ -gcs-download-prefix="${PREFIX}" \ -gcs-download-bucket-nvidia="${BUCKET}" \ -gcs-download-prefix-nvidia="${PREFIX}"
This command will:
cos-extensions to manage the GPU installation.cos-gpu-installer.nvidia-drivers-*.tgz) and the installer runfile from your GCS bucket and prefix.