diff --git a/CHANGELOG.md b/CHANGELOG.md index 3248d4857947105f1fe55621530d0f25deca8c5a..f337ad7c1ee9140eeaaa9923efd5e451de1e7bd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # FSL base project changelog +## 2107.3 (Monday 12th July 2021) + + - Change CUDA build configuration so that now all is needed is for `nvcc` to + be on the `$PATH`, or a `$NVCC` variable to be set. + + ## 2107.2 (Sunday 11th July 2021) - Further tweaks to CUDA linking logic. diff --git a/README.md b/README.md index f62db21b676528296e57ebecf387e96d2e5076f4..d4825b191e661db4ba10f3351ca25e270b03bfc5 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,17 @@ The `.ci` directory contains a collection of tests which validate the behaviour of various aspects of the `base` project. All tests are written in Python, and are executed with `pytest`. -## CUDA build options -The following options may be used to control compilation of a CUDA project: +## Building FSL CUDA projects. + +Some FSL projects (e.g. [`fsl/eddy`(https://git.fmrib.ox.ac.uk/fsl/eddy) use +CUDA for GPU acceleration. In order to compile these projects, the `nvcc` +compiler must be available on your `$PATH`, or a variable called `$NVCC` must +refer to the `nvcc` executable to use. + +The following additional options may be used to control compilation of a CUDA +project: - - `CUDA_HOME`: Specify the path to the CUDA installation directory - `CUDA_STATIC`: Statically link against the CUDA runtime and certain; CUDA Toolkit libraris (default is to use dynamic linking). - `GENCODEFLAGS`: `-gencode` options specifying the device architectures to @@ -31,4 +37,8 @@ The following options may be used to control compilation of a CUDA project: For example, to compile a CUDA project with a specific CUDA installation, and using static linking: - make CUDA_STATIC=1 CUDA_HOME=/usr/local/cuda-10.1 + export PATH=/usr/local/cuda-10.2/bin:$PATH + make CUDA_STATIC=1 + +The `Makefile` for each FSL CUDA project may provide additional options for +controlling compilation. diff --git a/config/buildSettings.mk b/config/buildSettings.mk index 4bccbcffc4e3c845e9234fd9f3b8af27121b0c23..e74b761e9ed6d6e45bbb5bf123347eeb1b09a905 100644 --- a/config/buildSettings.mk +++ b/config/buildSettings.mk @@ -114,25 +114,17 @@ endif ##################################################################### # # Default compiler commands, flags, and basic external libraries for -# CUDA projects. +# CUDA projects. nvcc must be on the $PATH, or $NVCC must be set. # ##################################################################### - -ifneq ($(shell which nvcc), ) - - # NVCC, CUDA_HOME, CUDA_VER, GENCODEFLAGS, - # NVCCFLAGS, NVCCLDFLAGS, and CUDA_STATIC - # may be specified/overridden by the - # environment. - - # We specifically use variable names "CUDA_VER" - # and "CUDA_HOME" because they will be set in - # the conda-forge CUDA build environment (and - # will take precedence over these definitions - # here when they are set). - NVCC ?= nvcc - CUDA_HOME ?= ${FSLDIR} - CUDA_VER ?= $(shell nvcc --version | grep -Po "release \K[0-9\.]+") +NVCC ?= $(shell which nvcc) +ifneq (${NVCC}, ) + + # NVCC, GENCODEFLAGS, NVCCFLAGS, NVCCLDFLAGS, + # and CUDA_STATIC may be specified/overridden + # by the environment. + CUDA_HOME = $(shell dirname ${NVCC})/../ + CUDA_VER = $(shell ${NVCC} --version | grep -Po "release \K[0-9\.]+") GENCODEFLAGS ?= $(shell ${FSLCONFDIR}/supportedGencodes.sh ${CUDA_VER}) # We specify the compiler to use with -ccbin, as @@ -151,6 +143,8 @@ ifneq ($(shell which nvcc), ) # Link CUDA libraries statically, if compilation # was invoked with "make CUDA_STATIC=1". + # Compiler / linker options vary depending on the + # CUDA version _CUDALIBS = -lcuda ifdef CUDA_STATIC # The cuda/cudart/cudadevrt libs are handled by nvcc. @@ -176,7 +170,11 @@ ifneq ($(shell which nvcc), ) _CUDALIBS += $(subst -lcublas,${CUBLAS_STATIC}, \ $(subst -lcurand,-lcurand_static,${CUDALIBS})) else - NVCCFLAGS += --cudart=shared --cudadevrt=static - _CUDALIBS += ${CUDALIBS} + ifeq ($(patsubst 9.%,,${CUDA_VER}),) + NVCCFLAGS += --cudart=shared + else + NVCCFLAGS += --cudart=shared --cudadevrt=static + endif + _CUDALIBS += ${CUDALIBS} endif endif