diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..aa18d28a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +data/* +log/* +*.pyc diff --git a/models/pointnet2_cls_ssg.py b/models/pointnet2_cls_ssg.py index c750c42d..bd463b4e 100644 --- a/models/pointnet2_cls_ssg.py +++ b/models/pointnet2_cls_ssg.py @@ -7,7 +7,8 @@ BASE_DIR = os.path.dirname(__file__) sys.path.append(BASE_DIR) sys.path.append(os.path.join(BASE_DIR, '../utils')) -import tensorflow as tf +import tensorflow.compat.v1 as tf +tf.disable_v2_behavior() import numpy as np import tf_util from pointnet_util import pointnet_sa_module diff --git a/tf_ops/3d_interpolation/tf_interpolate_compile.sh b/tf_ops/3d_interpolation/tf_interpolate_compile.sh index 34c9fdac..f283064a 100644 --- a/tf_ops/3d_interpolation/tf_interpolate_compile.sh +++ b/tf_ops/3d_interpolation/tf_interpolate_compile.sh @@ -1,5 +1,8 @@ # TF1.2 -g++ -std=c++11 tf_interpolate.cpp -o tf_interpolate_so.so -shared -fPIC -I /usr/local/lib/python2.7/dist-packages/tensorflow/include -I /usr/local/cuda-8.0/include -lcudart -L /usr/local/cuda-8.0/lib64/ -O2 -D_GLIBCXX_USE_CXX11_ABI=0 +#g++ -std=c++11 tf_interpolate.cpp -o tf_interpolate_so.so -shared -fPIC -I /usr/local/lib/python2.7/dist-packages/tensorflow/include -I /usr/local/cuda-8.0/include -lcudart -L /usr/local/cuda-8.0/lib64/ -O2 -D_GLIBCXX_USE_CXX11_ABI=0 # TF1.4 -#g++ -std=c++11 tf_interpolate.cpp -o tf_interpolate_so.so -shared -fPIC -I /usr/local/lib/python2.7/dist-packages/tensorflow/include -I /usr/local/cuda-8.0/include -I /usr/local/lib/python2.7/dist-packages/tensorflow/include/external/nsync/public -lcudart -L /usr/local/cuda-8.0/lib64/ -L/usr/local/lib/python2.7/dist-packages/tensorflow -ltensorflow_framework -O2 -D_GLIBCXX_USE_CXX11_ABI=0 +#g++ -std=c++11 tf_interpolate.cpp -o tf_interpolate_so.so -shared -fPIC -I /usr/local/lib/python2.7/dist-packages/tensorflow/include -I /usr/local/cuda-10.0/include -I /usr/local/lib/python2.7/dist-packages/tensorflow/include/external/nsync/public -lcudart -L /usr/local/cuda-10.0/lib64/ -L/usr/local/lib/python2.7/dist-packages/tensorflow -ltensorflow_framework -O2 -D_GLIBCXX_USE_CXX11_ABI=0 + +# TF2.0 +g++ -std=c++11 tf_interpolate.cpp -o tf_interpolate_so.so -shared -fPIC -I /usr/local/lib/python2.7/dist-packages/tensorflow_core/include -I /usr/local/cuda-10.0/include -I /usr/local/lib/python2.7/dist-packages/tensorflow_core/include/external/nsync/public -lcudart -L /usr/local/cuda-10.0/lib64/ -L /usr/local/lib/python2.7/dist-packages/tensorflow_core -ltensorflow_framework -O2 -D_GLIBCXX_USE_CXX11_ABI=0 diff --git a/tf_ops/grouping/tf_grouping_compile.sh b/tf_ops/grouping/tf_grouping_compile.sh index b193367d..e0452315 100644 --- a/tf_ops/grouping/tf_grouping_compile.sh +++ b/tf_ops/grouping/tf_grouping_compile.sh @@ -1,8 +1,15 @@ #/bin/bash -/usr/local/cuda-8.0/bin/nvcc tf_grouping_g.cu -o tf_grouping_g.cu.o -c -O2 -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC +# CUDA 8.0 +#/usr/local/cuda-8.0/bin/nvcc tf_sampling_g.cu -o tf_sampling_g.cu.o -c -O2 -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC + +# CUDA 10.0 +/usr/local/cuda-10.0/bin/nvcc tf_grouping_g.cu -o tf_grouping_g.cu.o -c -O2 -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC # TF1.2 -g++ -std=c++11 tf_grouping.cpp tf_grouping_g.cu.o -o tf_grouping_so.so -shared -fPIC -I /usr/local/lib/python2.7/dist-packages/tensorflow/include -I /usr/local/cuda-8.0/include -lcudart -L /usr/local/cuda-8.0/lib64/ -O2 -D_GLIBCXX_USE_CXX11_ABI=0 +#g++ -std=c++11 tf_grouping.cpp tf_grouping_g.cu.o -o tf_grouping_so.so -shared -fPIC -I /usr/local/lib/python2.7/dist-packages/tensorflow/include -I /usr/local/cuda-10.0/include -lcudart -L /usr/local/cuda-10.0/lib64/ -O2 -D_GLIBCXX_USE_CXX11_ABI=0 # TF1.4 -#g++ -std=c++11 tf_grouping.cpp tf_grouping_g.cu.o -o tf_grouping_so.so -shared -fPIC -I /usr/local/lib/python2.7/dist-packages/tensorflow/include -I /usr/local/cuda-8.0/include -I /usr/local/lib/python2.7/dist-packages/tensorflow/include/external/nsync/public -lcudart -L /usr/local/cuda-8.0/lib64/ -L/usr/local/lib/python2.7/dist-packages/tensorflow -ltensorflow_framework -O2 -D_GLIBCXX_USE_CXX11_ABI=0 +#g++ -std=c++11 tf_grouping.cpp tf_grouping_g.cu.o -o tf_grouping_so.so -shared -fPIC -I /usr/local/lib/python2.7/dist-packages/tensorflow/include -I /usr/local/cuda-10.0/include -I /usr/local/lib/python2.7/dist-packages/tensorflow/include/external/nsync/public -lcudart -L /usr/local/cuda-10.0/lib64/ -L/usr/local/lib/python2.7/dist-packages/tensorflow -ltensorflow_framework -O2 -D_GLIBCXX_USE_CXX11_ABI=0 + +# TF2.0 +g++ -std=c++11 tf_grouping.cpp tf_grouping_g.cu.o -o tf_grouping_so.so -shared -fPIC -I /usr/local/lib/python2.7/dist-packages/tensorflow_core/include -I /usr/local/cuda-10.0/include -I /usr/local/lib/python2.7/dist-packages/tensorflow_core/include/external/nsync/public -lcudart -L /usr/local/cuda-10.0/lib64/ -L /usr/local/lib/python2.7/dist-packages/tensorflow_core -ltensorflow_framework -O2 -D_GLIBCXX_USE_CXX11_ABI=0 diff --git a/tf_ops/sampling/tf_sampling_compile.sh b/tf_ops/sampling/tf_sampling_compile.sh index ed903f04..62061537 100644 --- a/tf_ops/sampling/tf_sampling_compile.sh +++ b/tf_ops/sampling/tf_sampling_compile.sh @@ -1,8 +1,15 @@ #/bin/bash -/usr/local/cuda-8.0/bin/nvcc tf_sampling_g.cu -o tf_sampling_g.cu.o -c -O2 -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC +# CUDA 8.0 +#/usr/local/cuda-8.0/bin/nvcc tf_sampling_g.cu -o tf_sampling_g.cu.o -c -O2 -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC + +# CUDA 10.0 +/usr/local/cuda-10.0/bin/nvcc tf_sampling_g.cu -o tf_sampling_g.cu.o -c -O2 -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC # TF1.2 -g++ -std=c++11 tf_sampling.cpp tf_sampling_g.cu.o -o tf_sampling_so.so -shared -fPIC -I /usr/local/lib/python2.7/dist-packages/tensorflow/include -I /usr/local/cuda-8.0/include -lcudart -L /usr/local/cuda-8.0/lib64/ -O2 -D_GLIBCXX_USE_CXX11_ABI=0 +#g++ -std=c++11 tf_sampling.cpp tf_sampling_g.cu.o -o tf_sampling_so.so -shared -fPIC -I /usr/local/lib/python2.7/dist-packages/tensorflow/include -I /usr/local/cuda-8.0/include -lcudart -L /usr/local/cuda-8.0/lib64/ -O2 -D_GLIBCXX_USE_CXX11_ABI=0 # TF1.4 #g++ -std=c++11 tf_sampling.cpp tf_sampling_g.cu.o -o tf_sampling_so.so -shared -fPIC -I /usr/local/lib/python2.7/dist-packages/tensorflow/include -I /usr/local/cuda-8.0/include -I /usr/local/lib/python2.7/dist-packages/tensorflow/include/external/nsync/public -lcudart -L /usr/local/cuda-8.0/lib64/ -L/usr/local/lib/python2.7/dist-packages/tensorflow -ltensorflow_framework -O2 -D_GLIBCXX_USE_CXX11_ABI=0 + +# TF2.0 +g++ -std=c++11 tf_sampling.cpp tf_sampling_g.cu.o -o tf_sampling_so.so -shared -fPIC -I /usr/local/lib/python2.7/dist-packages/tensorflow_core/include -I /usr/local/cuda-10.0/include -I /usr/local/lib/python2.7/dist-packages/tensorflow_core/include/external/nsync/public -lcudart -L /usr/local/cuda-10.0/lib64/ -L /usr/local/lib/python2.7/dist-packages/tensorflow_core -ltensorflow_framework -O2 -D_GLIBCXX_USE_CXX11_ABI=0 diff --git a/train.py b/train.py index 4fc982e9..7c009f34 100644 --- a/train.py +++ b/train.py @@ -7,7 +7,9 @@ from datetime import datetime import h5py import numpy as np -import tensorflow as tf +import tensorflow.compat.v1 as tf +tf.disable_v2_behavior() + import socket import importlib import os diff --git a/utils/pointnet_util.py b/utils/pointnet_util.py index 6d326233..fe1d7de2 100644 --- a/utils/pointnet_util.py +++ b/utils/pointnet_util.py @@ -15,7 +15,8 @@ from tf_sampling import farthest_point_sample, gather_point from tf_grouping import query_ball_point, group_point, knn_point from tf_interpolate import three_nn, three_interpolate -import tensorflow as tf +import tensorflow.compat.v1 as tf +tf.disable_v2_behavior() import numpy as np import tf_util diff --git a/utils/tf_util.py b/utils/tf_util.py index 4a8ffb70..64f52427 100644 --- a/utils/tf_util.py +++ b/utils/tf_util.py @@ -5,7 +5,9 @@ """ import numpy as np -import tensorflow as tf +import tensorflow.compat.v1 as tf +tf.disable_v2_behavior() + def _variable_on_cpu(name, shape, initializer, use_fp16=False): """Helper to create a Variable stored on CPU memory. @@ -39,7 +41,7 @@ def _variable_with_weight_decay(name, shape, stddev, wd, use_xavier=True): Variable Tensor """ if use_xavier: - initializer = tf.contrib.layers.xavier_initializer() + initializer = tf.keras.initializers.glorot_normal else: initializer = tf.truncated_normal_initializer(stddev=stddev) var = _variable_on_cpu(name, shape, initializer) @@ -524,11 +526,9 @@ def batch_norm_template(inputs, is_training, scope, moments_dims_unused, bn_deca normed: batch-normalized maps """ bn_decay = bn_decay if bn_decay is not None else 0.9 - return tf.contrib.layers.batch_norm(inputs, + return tf.layers.batch_normalization(inputs, center=True, scale=True, - is_training=is_training, decay=bn_decay,updates_collections=None, - scope=scope, - data_format=data_format) + training=is_training) def batch_norm_for_fc(inputs, is_training, bn_decay, scope):