Skip to content

Commit 45066ad

Browse files
authored
feat: allow explicitly disabling CUDA step (#1588)
1 parent af944e4 commit 45066ad

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

exla/Makefile

+9-7
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,29 @@ else
3636
CFLAGS += -O3
3737
endif
3838

39+
NVCC := $(CXX)
40+
NVCCFLAGS = $(CFLAGS)
3941
LDFLAGS = -L$(XLA_EXTENSION_LIB) -lxla_extension -shared -fvisibility=hidden
4042

4143
ifeq ($(CROSSCOMPILE),)
4244
# Interrogate the system for local compilation
4345
UNAME_S = $(shell uname -s)
4446

47+
ifdef ($(EXLA_CPU_ONLY),)
48+
$(info EXLA_CPU_ONLY is not set, checking for nvcc availability)
4549
NVCC_RESULT := $(shell which nvcc 2> /dev/null)
4650
NVCC_TEST := $(notdir $(NVCC_RESULT))
4751

48-
ifeq ($(NVCC_TEST),nvcc)
49-
NVCC := nvcc
50-
NVCCFLAGS += -DCUDA_ENABLED
52+
ifeq ($(NVCC_TEST),nvcc)
53+
NVCC := nvcc
54+
NVCCFLAGS += -DCUDA_ENABLED
55+
endif
5156
else
52-
NVCC := $(CXX)
53-
NVCCFLAGS = $(CFLAGS)
57+
$(info EXLA_CPU_ONLY is set, skipping nvcc step)
5458
endif
5559
else
5660
# Determine settings for cross-compiled builds like for Nerves
5761
UNAME_S = Linux
58-
NVCC := $(CXX)
59-
NVCCFLAGS = $(CFLAGS)
6062
endif
6163

6264
ifeq ($(UNAME_S), Darwin)

exla/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ EXLA relies on the [XLA](https://github.com/elixir-nx/xla) package to provide th
4343
* Incompatible protocol buffer versions
4444
* Error message: "this file was generated by an older version of protoc which is incompatible with your Protocol Buffer headers".
4545
* If you have `protoc` installed on your machine, it may conflict with the `protoc` precompiled inside XLA. Uninstall, unlink, or remove `protoc` from your path to continue.
46+
* Missing CUDA symbols
47+
* In some cases, you might be compiling a CPU-only version of `:xla` in an environment that has CUDA available. For these cases, you can set the `EXLA_CPU_ONLY` environment variable to any value to disable custom CUDA functionality in EXLA.
4648

4749
### Usage with Nerves
4850

0 commit comments

Comments
 (0)