Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 5cd8bf5

Browse files
authored
Merge pull request #214 from NervanaSystems/peter/makefile_tf_fix
Update makefile to include tf-mkl
2 parents 9fd5d4f + 92dbd6f commit 5cd8bf5

File tree

3 files changed

+81
-4
lines changed

3 files changed

+81
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ generated
2525
.idea/
2626
dist
2727
.nlp_architect_env/
28+
_generated_reqs.txt

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ DOC_PUB_RELEASE_PATH := $(DOC_PUB_PATH)/$(RELEASE)
2121

2222
LIBRARY_NAME := nlp_architect
2323
VIRTUALENV_DIR := .nlp_architect_env
24-
REQ_FILE := requirements.txt
24+
REQ_FILE := _generated_reqs.txt
2525
ACTIVATE := $(VIRTUALENV_DIR)/bin/activate
2626
MODELS_DIR := $(LIBRARY_NAME)/models
2727
NLP_DIR := $(LIBRARY_NAME)/nlp
@@ -57,10 +57,18 @@ html: doc_prepare $(ACTIVATE)
5757
clean:
5858
@echo "Cleaning files.."
5959
@rm -rf $(VIRTUALENV_DIR)
60+
@rm -rf $(REQ_FILE)
6061

6162
ENV_EXIST := $(shell test -d $(VIRTUALENV_DIR) && echo -n yes)
63+
REQ_EXIST := $(shell test -f $(REQ_FILE) && echo -n yes)
6264

63-
$(ACTIVATE):
65+
$(REQ_FILE):
66+
ifneq ($(REQ_EXIST), yes)
67+
@echo "Generating pip requirements file"
68+
@bash generate_reqs.sh
69+
endif
70+
71+
$(ACTIVATE): $(REQ_FILE)
6472
ifneq ($(ENV_EXIST), yes)
6573
@echo "NLP Architect installation"
6674
@echo "**************************"
@@ -83,14 +91,14 @@ dev: pre_install
8391
@. $(ACTIVATE); pip install -e .
8492
$(MAKE) print_finish
8593

86-
install_no_virt_env:
94+
install_no_virt_env: $(REQ_FILE)
8795
@echo "\n\n****************************************"
8896
@echo "Installing NLP Architect in current python env"
8997
pip install -r $(REQ_FILE)
9098
pip install -e .
9199
@echo "NLP Architect setup complete."
92100

93-
sysinstall:
101+
sysinstall: $(REQ_FILE)
94102
@echo "\n\n****************************************"
95103
@echo "Installing NLP Architect in current python env (system install)"
96104
pip install -r $(REQ_FILE)

generate_reqs.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash -e
2+
# ******************************************************************************
3+
# Copyright 2017-2018 Intel Corporation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
# ******************************************************************************
17+
18+
# optimized pacakge links
19+
tf_ver='1.6.0'
20+
tf_to_install='tensorflow=='${tf_ver}
21+
tf35='https://anaconda.org/intel/tensorflow/1.6.0/download/tensorflow-1.6.0-cp35-cp35m-linux_x86_64.whl'
22+
tf36='https://anaconda.org/intel/tensorflow/1.6.0/download/tensorflow-1.6.0-cp36-cp36m-linux_x86_64.whl'
23+
24+
25+
# detect python version and OS
26+
pyver=`python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))'`
27+
platform='other'
28+
unamestr=`uname`
29+
if [[ "$unamestr" == 'Linux' ]]; then
30+
platform='linux'
31+
fi
32+
33+
ask_which_tf() {
34+
read -p 'Install Tensorflow MKL-DNN ? [Y/n] ' install_opt_tf
35+
retval=0
36+
case "${install_opt_tf}" in
37+
y|Y ) retval=1;;
38+
n|N ) retval=0;;
39+
"" ) retval=0;;
40+
esac
41+
if [ ${retval} == 1 ];
42+
then
43+
if [ ${pyver} == 3.5 ];
44+
then
45+
echo python 3.5 detected;
46+
tf_to_install=${tf35};
47+
elif [ ${pyver} == 3.6 ];
48+
then
49+
echo python 3.6 detected;
50+
tf_to_install=${tf36};
51+
fi
52+
fi
53+
}
54+
55+
if [ ${pyver} == 3.5 ] || [ ${pyver} == 3.6 ] ;
56+
then
57+
if [ ${platform} == 'linux' ] ;
58+
then
59+
ask_which_tf
60+
fi
61+
fi
62+
63+
# read file
64+
while read line
65+
do
66+
line=${line/tensorflow*/$tf_to_install}
67+
echo "$line"
68+
done < requirements.txt > _generated_reqs.txt

0 commit comments

Comments
 (0)