From b262fb556c20a89282d6a80b894d2057dc519c60 Mon Sep 17 00:00:00 2001 From: Konstantin Lopuhin Date: Mon, 20 May 2019 16:14:12 +0000 Subject: [PATCH 1/2] Allow forcing GPU build with FORCE_CUDA=1 This is convenient to e.g. build with GPU support inside a docker image --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a12a3a61486..165f4cea7eb 100644 --- a/setup.py +++ b/setup.py @@ -88,7 +88,7 @@ def get_extensions(): define_macros = [] - if torch.cuda.is_available() and CUDA_HOME is not None: + if (torch.cuda.is_available() and CUDA_HOME is not None) or os.getenv('FORCE_CUDA', '0') == '1': extension = CUDAExtension sources += source_cuda define_macros += [('WITH_CUDA', None)] From 3ae13dc80c1aa3441230792de49059687432932c Mon Sep 17 00:00:00 2001 From: Konstantin Lopuhin Date: Tue, 21 May 2019 08:40:35 +0000 Subject: [PATCH 2/2] Document FORCE_CUDA --- README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.rst b/README.rst index 81db70b073b..d5ba421c4e3 100644 --- a/README.rst +++ b/README.rst @@ -37,6 +37,9 @@ From source: python setup.py install +By default, GPU support is built if CUDA is found and ``torch.cuda.is_available()`` is true. +It's possible to force building GPU support by setting ``FORCE_CUDA=1`` environment variable, +which is useful when building a docker image. Image Backend =============