Skip to content

Instantly share code, notes, and snippets.

@namgo
Created December 5, 2023 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save namgo/9aeeee2025b341779be85e596822893f to your computer and use it in GitHub Desktop.
Save namgo/9aeeee2025b341779be85e596822893f to your computer and use it in GitHub Desktop.
Extract cuda to something that might be packageable
#!/bin/bash
#
# initialize /opt/cuda-12.2.2/extract with ./cuda_12.2.2_535.104.05_linux.run --extract=/opt/cuda-12.2.2/extract
# (from: https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux.run)
#
# IMPORTANT: this currently ignores nsight_{systems,compute}/
# https://developer.nvidia.com/nsight-systems it's a performance analysis tool, so pretty important!
# this includes bin/nsys
VER="12.2.2"
OUTDIR=/opt/_CUDA-$VER
INDIR=/opt/cuda-12.2.2/extract
ARCH=x86_64-linux
mkdir -p $OUTDIR/bin
for _DIR in $INDIR/*/bin/; do
cp -rv $_DIR/* $OUTDIR/bin/
done
for _DIR in $INDIR/*/targets/$ARCH/; do
cp -rv $_DIR $OUTDIR/
done
cp -rv $INDIR/cuda_nvcc/nvmm/bin/* $OUTDIR/bin/
cp -rv $INDIR/cuda_nvcc/nvmm/lib64/* $OUTDIR/$ARCH/lib/
cp -rv $INDIR/cuda_nvcc/nvmm/include/* $OUTDIR/$ARCH/include/
# NOTE: libdevice will have to be exported later
cp -rv $INDIR/cuda_nvcc/nvmm/libdevice/ $OUTDIR/
ln -s $OUTDIR/$ARCH/lib $OUTDIR/lib
ln -s $OUTDIR/$ARCH/lib $OUTDIR/lib64
ln -s $OUTDIR/$ARCH/include $OUTDIR/include
echo "export NVCC=$OUTDIR/bin/nvcc LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$OUTDIR/lib64/ PATH=\$PATH:$OUTDIR/bin/ CUDA_PATH=$OUTDIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment