forked from microsoft/nni
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
150 lines (113 loc) · 4.74 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
BIN_PATH ?= ${HOME}/.local/bin
INSTALL_PREFIX ?= ${HOME}/.local
PIP_MODE ?= --user
EXAMPLES_PATH ?= ${HOME}/nni/examples
WHOAMI := $(shell whoami)
.PHONY: build install uninstall dev-install
YARN := $(INSTALL_PREFIX)/yarn/bin/yarn
build:
### Building NNI Manager ###
cd src/nni_manager && yarn && yarn build
### Building Web UI ###
cd src/webui && yarn && yarn build
### Building Python SDK ###
cd src/sdk/pynni && python3 setup.py build
### Building nnictl ###
cd tools && python3 setup.py build
install:
ifneq ('$(HOME)', '/root')
ifeq (${WHOAMI}, root)
### Sorry, sudo make install is not supported ###
exit 1
endif
endif
mkdir -p $(BIN_PATH)
mkdir -p $(INSTALL_PREFIX)/nni
mkdir -p $(EXAMPLES_PATH)
### Installing NNI Manager ###
cp -rT src/nni_manager/dist $(INSTALL_PREFIX)/nni/nni_manager
cp -rT src/nni_manager/node_modules $(INSTALL_PREFIX)/nni/nni_manager/node_modules
### Installing Web UI ###
cp -rT src/webui/build $(INSTALL_PREFIX)/nni/webui
ln -sf $(INSTALL_PREFIX)/nni/nni_manager/node_modules/serve/bin/serve.js $(BIN_PATH)/serve
### Installing Python SDK dependencies ###
pip3 install $(PIP_MODE) -r src/sdk/pynni/requirements.txt
### Installing Python SDK ###
cd src/sdk/pynni && python3 setup.py install $(PIP_MODE)
### Installing nnictl ###
cd tools && python3 setup.py install $(PIP_MODE)
echo '#!/bin/sh' > $(BIN_PATH)/nnimanager
echo 'cd $(INSTALL_PREFIX)/nni/nni_manager && node main.js $$@' >> $(BIN_PATH)/nnimanager
chmod +x $(BIN_PATH)/nnimanager
echo '#!/bin/sh' > $(BIN_PATH)/nnictl
echo 'NNI_MANAGER=$(BIN_PATH)/nnimanager WEB_UI_FOLDER=$(INSTALL_PREFIX)/nni/webui python3 -m nnicmd.nnictl $$@' >> $(BIN_PATH)/nnictl
chmod +x $(BIN_PATH)/nnictl
### Installing examples ###
cp -rT examples $(EXAMPLES_PATH)
pip-install:
ifneq ('$(HOME)', '/root')
ifeq (${WHOAMI}, root)
### Sorry, sudo make install is not supported ###
exit 1
endif
endif
### Prepare Node.js ###
wget https://nodejs.org/dist/v10.9.0/node-v10.9.0-linux-x64.tar.xz
tar xf node-v10.9.0-linux-x64.tar.xz
cp -rT node-v10.9.0-linux-x64 $(INSTALL_PREFIX)/node
### Prepare Yarn 1.9.4 ###
wget https://github.com/yarnpkg/yarn/releases/download/v1.9.4/yarn-v1.9.4.tar.gz
tar xf yarn-v1.9.4.tar.gz
cp -rT yarn-v1.9.4 $(INSTALL_PREFIX)/yarn
### Export PATH for node and yarn, and build NNI Manager ###
export PATH=$(INSTALL_PREFIX)/node/bin:$(INSTALL_PREFIX)/yarn/bin:$(PATH) && cd src/nni_manager && $(YARN) && $(YARN) build
### Building Web UI ###
export PATH=$(INSTALL_PREFIX)/node/bin:$(INSTALL_PREFIX)/yarn/bin:$(PATH) && cd src/webui && $(YARN) && $(YARN) build
mkdir -p $(BIN_PATH)
mkdir -p $(INSTALL_PREFIX)/nni
mkdir -p $(EXAMPLES_PATH)
### Installing NNI Manager ###
cp -rT src/nni_manager/dist $(INSTALL_PREFIX)/nni/nni_manager
cp -rT src/nni_manager/node_modules $(INSTALL_PREFIX)/nni/nni_manager/node_modules
echo '#!/bin/sh' > $(BIN_PATH)/nnimanager
echo 'cd $(INSTALL_PREFIX)/nni/nni_manager && node main.js $$@' >> $(BIN_PATH)/nnimanager
chmod +x $(BIN_PATH)/nnimanager
echo '#!/bin/sh' > $(BIN_PATH)/nnictl
echo 'NNI_MANAGER=$(BIN_PATH)/nnimanager WEB_UI_FOLDER=$(INSTALL_PREFIX)/nni/webui python3 -m nnicmd.nnictl $$@' >> $(BIN_PATH)/nnictl
chmod +x $(BIN_PATH)/nnictl
### Installing Web UI ###
cp -rT src/webui/build $(INSTALL_PREFIX)/nni/webui
ln -sf $(INSTALL_PREFIX)/nni/nni_manager/node_modules/serve/bin/serve.js $(BIN_PATH)/serve
### Installing examples ###
cp -rT examples $(EXAMPLES_PATH)
dev-install:
mkdir -p $(BIN_PATH)
mkdir -p $(INSTALL_PREFIX)/nni
### Installing NNI Manager ###
ln -sf $(INSTALL_PREFIX)/nni/nni_manager $(PWD)/src/nni_manager/dist
ln -sf $(INSTALL_PREFIX)/nni/nni_manager/node_modules $(PWD)/src/nni_manager/node_modules
### Installing Web UI ###
ln -sf $(INSTALL_PREFIX)/nni/webui $(PWD)/src/webui
ln -sf $(INSTALL_PREFIX)/nni/nni_manager/node_modules/serve/bin/serve.js $(BIN_PATH)/serve
### Installing Python SDK dependencies ###
pip3 install $(PIP_MODE) -r src/sdk/pynni/requirements.txt
### Installing Python SDK ###
cd src/sdk/pynni && pip3 install $(PIP_MODE) -e .
### Installing nnictl ###
cd tools && pip3 install $(PIP_MODE) -e .
echo '#!/bin/sh' > $(BIN_PATH)/nnimanager
echo 'cd $(INSTALL_PREFIX)/nni/nni_manager && node main.js $$@' >> $(BIN_PATH)/nnimanager
chmod +x $(BIN_PATH)/nnimanager
echo '#!/bin/sh' > $(BIN_PATH)/nnictl
echo 'NNI_MANAGER=$(BIN_PATH)/nnimanager python3 -m nnicmd.nnictl $$@' >> $(BIN_PATH)/nnictl
chmod +x $(BIN_PATH)/nnictl
### Installing examples ###
ln -sf $(EXAMPLES_PATH) $(PWD)/examples
uninstall:
-pip3 uninstall -y nni
-pip3 uninstall -y nnictl
-rm -r $(INSTALL_PREFIX)/nni
-rm -r $(EXAMPLES_PATH)
-rm $(BIN_PATH)/serve
-rm $(BIN_PATH)/nnimanager
-rm $(BIN_PATH)/nnictl