Makefile 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # top level makefile for Go server
  2. include make/common-defs.make
  3. RUNNER_TARGETS := default
  4. # Determine which if any GPU runners we should build
  5. ifeq ($(OS),windows)
  6. CUDA_PATH?=$(shell cygpath -m -s "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\" 2>/dev/null)unknown
  7. CUDA_BASE_DIR := $(dir $(shell cygpath -m -s "$(CUDA_PATH)\\.." 2>/dev/null))
  8. CUDA_11:=$(shell ls -d $(CUDA_BASE_DIR)/v11.? 2>/dev/null)
  9. CUDA_12:=$(shell ls -d $(CUDA_BASE_DIR)/v12.? 2>/dev/null)
  10. HIP_PATH_83 := $(shell cygpath -m -s "$(subst \,/,$(HIP_PATH))" 2>/dev/null)
  11. HIP_LIB_DIR := $(shell ls -d $(HIP_PATH_83)/lib 2>/dev/null)
  12. else ifeq ($(OS),linux)
  13. HIP_PATH?=/opt/rocm
  14. HIP_LIB_DIR := $(shell ls -d $(HIP_PATH)/lib 2>/dev/null)
  15. CUDA_PATH?=/usr/local/cuda
  16. CUDA_11:=$(shell ls -d $(CUDA_PATH)-11 2>/dev/null)
  17. CUDA_12:=$(shell ls -d $(CUDA_PATH)-12 2>/dev/null)
  18. endif
  19. ifeq ($(OLLAMA_SKIP_CUDA_GENERATE),)
  20. ifneq ($(CUDA_11),)
  21. RUNNER_TARGETS += cuda_v11
  22. endif
  23. ifneq ($(CUDA_12),)
  24. RUNNER_TARGETS += cuda_v12
  25. endif
  26. endif
  27. ifeq ($(OLLAMA_SKIP_ROCM_GENERATE),)
  28. ifneq ($(HIP_LIB_DIR),)
  29. RUNNER_TARGETS += rocm
  30. endif
  31. endif
  32. all: clean-payload .WAIT runners
  33. runners: $(RUNNER_TARGETS)
  34. $(RUNNER_TARGETS):
  35. $(MAKE) -f make/Makefile.$@
  36. clean:
  37. rm -rf $(BUILD_DIR) $(DIST_RUNNERS) $(PAYLOAD_RUNNERS) $(RUNNERS_PAYLOAD_DIR)
  38. clean-payload:
  39. rm -rf $(addprefix $(RUNNERS_PAYLOAD_DIR)/, $(RUNNER_TARGETS) metal cpu cpu_avx cpu_avx2)
  40. .PHONY: all runners clean clean-payload $(RUNNER_TARGETS) .WAIT
  41. # Handy debugging for make variables
  42. print-%:
  43. @echo '$*=$($*)'