Makefile 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_LIB_DIR := $(shell ls -d $(HIP_PATH)/lib 2>/dev/null)
  11. else ifeq ($(OS),linux)
  12. HIP_PATH?=/opt/rocm
  13. HIP_LIB_DIR := $(shell ls -d $(HIP_PATH)/lib 2>/dev/null)
  14. CUDA_PATH?=/usr/local/cuda
  15. CUDA_11:=$(shell ls -d $(CUDA_PATH)-11 2>/dev/null)
  16. CUDA_12:=$(shell ls -d $(CUDA_PATH)-12 2>/dev/null)
  17. endif
  18. ifeq ($(OLLAMA_SKIP_CUDA_GENERATE),)
  19. ifneq ($(CUDA_11),)
  20. RUNNER_TARGETS += cuda_v11
  21. endif
  22. ifneq ($(CUDA_12),)
  23. RUNNER_TARGETS += cuda_v12
  24. endif
  25. endif
  26. ifeq ($(OLLAMA_SKIP_ROCM_GENERATE),)
  27. ifneq ($(HIP_LIB_DIR),)
  28. RUNNER_TARGETS += rocm
  29. endif
  30. endif
  31. all: clean-payload .WAIT runners
  32. runners: $(RUNNER_TARGETS)
  33. $(RUNNER_TARGETS):
  34. $(MAKE) -f make/Makefile.$@
  35. help-sync apply-patches create-patches sync:
  36. $(MAKE) -f make/Makefile.sync $@
  37. clean:
  38. rm -rf $(BUILD_DIR) $(DIST_RUNNERS) $(PAYLOAD_RUNNERS)
  39. go clean -cache
  40. clean-payload:
  41. rm -rf $(addprefix $(RUNNERS_PAYLOAD_DIR)/, $(RUNNER_TARGETS) metal cpu cpu_avx cpu_avx2)
  42. .PHONY: all runners clean clean-payload $(RUNNER_TARGETS) .WAIT
  43. # Handy debugging for make variables
  44. print-%:
  45. @echo '$*=$($*)'