Skip to content
Snippets Groups Projects
Commit abeb1239 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

Merge branch 'rf/default-cuda-home' into 'master'

Rf/default cuda home

See merge request fsl/base!16
parents 1c4672a5 dc2d0627
No related branches found
Tags 2107.3
1 merge request!16Rf/default cuda home
Pipeline #9630 passed
# 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.
......
......@@ -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.
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment