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 !16
parents 1c4672a5 dc2d0627
No related branches found
No related tags found
1 merge request!16Rf/default cuda home
Pipeline #9630 passed
# FSL base project changelog # 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) ## 2107.2 (Sunday 11th July 2021)
- Further tweaks to CUDA linking logic. - Further tweaks to CUDA linking logic.
......
...@@ -17,11 +17,17 @@ The `.ci` directory contains a collection of tests which validate the ...@@ -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 behaviour of various aspects of the `base` project. All tests are written
in Python, and are executed with `pytest`. 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_STATIC`: Statically link against the CUDA runtime and certain;
CUDA Toolkit libraris (default is to use dynamic linking). CUDA Toolkit libraris (default is to use dynamic linking).
- `GENCODEFLAGS`: `-gencode` options specifying the device architectures to - `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: ...@@ -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 For example, to compile a CUDA project with a specific CUDA installation, and
using static linking: 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 ...@@ -114,25 +114,17 @@ endif
##################################################################### #####################################################################
# #
# Default compiler commands, flags, and basic external libraries for # Default compiler commands, flags, and basic external libraries for
# CUDA projects. # CUDA projects. nvcc must be on the $PATH, or $NVCC must be set.
# #
##################################################################### #####################################################################
NVCC ?= $(shell which nvcc)
ifneq ($(shell which nvcc), ) ifneq (${NVCC}, )
# NVCC, CUDA_HOME, CUDA_VER, GENCODEFLAGS, # NVCC, GENCODEFLAGS, NVCCFLAGS, NVCCLDFLAGS,
# NVCCFLAGS, NVCCLDFLAGS, and CUDA_STATIC # and CUDA_STATIC may be specified/overridden
# may be specified/overridden by the # by the environment.
# environment. CUDA_HOME = $(shell dirname ${NVCC})/../
CUDA_VER = $(shell ${NVCC} --version | grep -Po "release \K[0-9\.]+")
# 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\.]+")
GENCODEFLAGS ?= $(shell ${FSLCONFDIR}/supportedGencodes.sh ${CUDA_VER}) GENCODEFLAGS ?= $(shell ${FSLCONFDIR}/supportedGencodes.sh ${CUDA_VER})
# We specify the compiler to use with -ccbin, as # We specify the compiler to use with -ccbin, as
...@@ -151,6 +143,8 @@ ifneq ($(shell which nvcc), ) ...@@ -151,6 +143,8 @@ ifneq ($(shell which nvcc), )
# Link CUDA libraries statically, if compilation # Link CUDA libraries statically, if compilation
# was invoked with "make CUDA_STATIC=1". # was invoked with "make CUDA_STATIC=1".
# Compiler / linker options vary depending on the
# CUDA version
_CUDALIBS = -lcuda _CUDALIBS = -lcuda
ifdef CUDA_STATIC ifdef CUDA_STATIC
# The cuda/cudart/cudadevrt libs are handled by nvcc. # The cuda/cudart/cudadevrt libs are handled by nvcc.
...@@ -176,7 +170,11 @@ ifneq ($(shell which nvcc), ) ...@@ -176,7 +170,11 @@ ifneq ($(shell which nvcc), )
_CUDALIBS += $(subst -lcublas,${CUBLAS_STATIC}, \ _CUDALIBS += $(subst -lcublas,${CUBLAS_STATIC}, \
$(subst -lcurand,-lcurand_static,${CUDALIBS})) $(subst -lcurand,-lcurand_static,${CUDALIBS}))
else else
NVCCFLAGS += --cudart=shared --cudadevrt=static ifeq ($(patsubst 9.%,,${CUDA_VER}),)
_CUDALIBS += ${CUDALIBS} NVCCFLAGS += --cudart=shared
else
NVCCFLAGS += --cudart=shared --cudadevrt=static
endif
_CUDALIBS += ${CUDALIBS}
endif endif
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