File size: 1,613 Bytes
67c4f10 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | CUDA_PATH ?= /usr/local/cuda
ifeq ($(wildcard $(CUDA_PATH)/bin/nvcc),)
CUDA_PATH := /usr
endif
NVCC := $(CUDA_PATH)/bin/nvcc
CXX := g++
NVCC_FLAGS := -O3 -c -Xcompiler -fPIC -std=c++17 -I. -I$(CUDA_PATH)/include
CXX_FLAGS := -O3 -fPIC -std=c++17 -I. -I$(CUDA_PATH)/include
LDFLAGS := -L$(CUDA_PATH)/lib64 -L. -lcublas -lcudart -Wl,-rpath,'$$ORIGIN' -Wl,-rpath,$(CUDA_PATH)/lib64
TARGET_LIB := libparvulus.so
TARGET_CLI := parvulus_runtime
TARGET_TEST := test_vision_encoder
.PHONY: all clean distclean test weights
all: $(TARGET_LIB) $(TARGET_CLI) $(TARGET_TEST)
weights:
@if [ ! -f parvulus_model_weights.bin ] || [ ! -f action_scale.bin ] || [ ! -f task_embeddings.bin ]; then \
python3 export_from_safetensors.py; \
fi
parvulus_engine.o: parvulus_engine.cu parvulus_engine.h vision_encoder.cu vision_encoder.cuh vision_encoder.h kernels.cuh
$(NVCC) $(NVCC_FLAGS) parvulus_engine.cu -o parvulus_engine.o
$(TARGET_LIB): parvulus_engine.o parvulus_c_api.cpp parvulus_c_api.h
$(CXX) -shared -fPIC parvulus_engine.o parvulus_c_api.cpp -o $(TARGET_LIB) $(CXX_FLAGS) $(LDFLAGS)
$(TARGET_CLI): parvulus_runtime_cli.cpp $(TARGET_LIB)
$(CXX) $(CXX_FLAGS) parvulus_runtime_cli.cpp -o $(TARGET_CLI) -lparvulus $(LDFLAGS)
$(TARGET_TEST): test_vision_encoder.cpp $(TARGET_LIB)
$(CXX) $(CXX_FLAGS) test_vision_encoder.cpp -o $(TARGET_TEST) -lparvulus $(LDFLAGS)
test: all weights
./$(TARGET_TEST)
./$(TARGET_CLI) --benchmark 20
clean:
rm -f parvulus_engine.o $(TARGET_LIB) $(TARGET_CLI) $(TARGET_TEST)
distclean: clean
rm -f parvulus_model_weights.bin action_scale.bin task_embeddings.bin *.onnx
|