|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set -e |
|
|
|
|
|
CONFIG="cpu" |
|
|
|
function tolower() { |
|
echo "${1,,}" |
|
} |
|
|
|
if [[ ! -z "$1" ]] |
|
then |
|
echo "Setting configuration from argument($1)..." |
|
CONFIG=$(tolower "$1") |
|
if [ "$CONFIG" != "cpu" ] && [ "$CONFIG" != "gpu" ] |
|
then |
|
echo "Configuration must be either \"cpu\" or \"gpu\", exiting..." |
|
exit 1 |
|
fi |
|
fi |
|
|
|
echo "Running configuration with $CONFIG." |
|
|
|
|
|
|
|
|
|
echo "-----------------------------------------------------------------------" |
|
echo "Compiling protobuf..." |
|
echo "-----------------------------------------------------------------------" |
|
protoc deeplab2/*.proto --python_out=. |
|
|
|
|
|
|
|
TF_CFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') ) |
|
TF_LFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') ) |
|
OP_NAME='deeplab2/tensorflow_ops/kernels/merge_semantic_and_instance_maps_op' |
|
|
|
if [ "$CONFIG" == "cpu" ] |
|
then |
|
|
|
echo "-----------------------------------------------------------------------" |
|
echo "Compiling the custom cc op: merge_semantic_and_instance_maps_op (CPU)..." |
|
echo "-----------------------------------------------------------------------" |
|
g++ -std=c++14 -shared \ |
|
${OP_NAME}.cc ${OP_NAME}_kernel.cc -o ${OP_NAME}.so -fPIC ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -O2 |
|
else |
|
|
|
|
|
echo "-----------------------------------------------------------------------" |
|
echo "Compiling the custom cc op: merge_semantic_and_instance_maps_op (GPU)..." |
|
echo "-----------------------------------------------------------------------" |
|
nvcc -std=c++14 -c -o ${OP_NAME}_kernel.cu.o \ |
|
${OP_NAME}_kernel.cu.cc \ |
|
${TF_CFLAGS[@]} -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC --expt-relaxed-constexpr |
|
|
|
g++ -std=c++14 -shared -o ${OP_NAME}.so ${OP_NAME}.cc ${OP_NAME}_kernel.cc \ |
|
${OP_NAME}_kernel.cu.o ${TF_CFLAGS[@]} -fPIC -lcudart ${TF_LFLAGS[@]} |
|
fi |
|
|
|
|
|
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/models:`pwd`/cocoapi/PythonAPI |
|
|
|
|
|
echo "-----------------------------------------------------------------------" |
|
echo "Running tests for merge_semantic_and_instance_maps_op..." |
|
echo "-----------------------------------------------------------------------" |
|
python deeplab2/tensorflow_ops/python/kernel_tests/merge_semantic_and_instance_maps_op_test.py |
|
|
|
|
|
echo "-----------------------------------------------------------------------" |
|
echo "Running end-to-end tests..." |
|
echo "-----------------------------------------------------------------------" |
|
|
|
|
|
python deeplab2/model/deeplab_test.py |
|
|
|
|
|
python deeplab2/trainer/evaluator_test.py |
|
|
|
echo "------------------------" |
|
echo "Done with configuration!" |
|
echo "------------------------" |
|
|
|
|