-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
44 lines (39 loc) · 1.77 KB
/
Makefile
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
UNAME := $(shell uname)
deps-macos:
@if [ -e "/tmp/libtorch.zip" ]; then \
echo "LibTorch for macOS already exists"; \
else \
echo "Downloading and Installing LibTorch for macOS"; \
curl -o /tmp/libtorch.zip https://download.pytorch.org/libtorch/cpu/libtorch-macos-2.1.2.zip; \
fi
@unzip /tmp/libtorch.zip -d /tmp
@sudo mv /tmp/libtorch /usr/local/libtorch
deps-linux:
@if [ -e "/tmp/libtorch.zip" ]; then \
echo "LibTorch for Linux already exists"; \
else \
echo "Downloading and Installing LibTorch for Linux"; \
curl -o /tmp/libtorch.zip https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.1.2%2Bcpu.zip \
fi
@unzip /tmp/libtorch.zip -d /tmp
@sudo mv /tmp/libtorch /usr/local/libtorch
deps:
@if [ "$(UNAME)" = "Darwin" ]; then \
$(MAKE) deps-macos; \
else \
$(MAKE) deps-linux; \
fi
@echo "Downloaing Go Dependencies"
@go mod download
run:
@if [ "$(UNAME)" = "Darwin" ]; then \
export LIBRARY_PATH="/usr/local/libtorch/lib:${LIBRARY_PATH}" && \
export DYLD_LIBRARY_PATH="/usr/local/libtorch/lib:${DYLD_LIBRARY_PATH}" && \
export C_INCLUDE_PATH="/usr/local/libtorch/include:/usr/local/libtorch/include/torch/csrc/api/include:${C_INCLUDE_PATH}" && \
export CPLUS_INCLUDE_PATH="/usr/local/libtorch/include:/usr/local/libtorch/include/torch/csrc/api/include:${CPLUS_INCLUDE_PATH}" && go run main.go; \
else \
export LIBRARY_PATH="/usr/local/libtorch/lib:${LIBRARY_PATH}" && \
export LD_LIBRARY_PATH="/usr/local/libtorch/lib:${LD_LIBRARY_PATH}" && \
export C_INCLUDE_PATH="/usr/local/libtorch/include:/usr/local/libtorch/include/torch/csrc/api/include:${C_INCLUDE_PATH}" && \
export CPLUS_INCLUDE_PATH="/usr/local/libtorch/include:/usr/local/libtorch/include/torch/csrc/api/include:${CPLUS_INCLUDE_PATH}" go run main.go; \
fi