Last active
May 22, 2019 13:25
-
-
Save takiyu/08f339f580806b7878aeddcf33a5f711 to your computer and use it in GitHub Desktop.
Dirt Install Memo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ # Install bazel 0.5.4 | |
$ wget https://github.com/bazelbuild/bazel/releases/download/0.5.4/bazel-0.5.4-installer-linux-x86_64.sh | |
$ chmod +x bazel-0.5.4-installer-linux-x86_64.sh | |
$ ./bazel-0.5.4-installer-linux-x86_64.sh --user | |
$ # Install tensorflow 1.4 (CUDA 10.1, cuDNN 7.5.1) | |
$ git clone https://github.com/tensorflow/tensorflow.git | |
$ git checkout r1.4 | |
$ ./configure --disable-multilib | |
WARNING: ignoring _JAVA_OPTIONS in environment. | |
WARNING: Running Bazel server needs to be killed, because the startup options are different. | |
You have bazel 0.5.4 installed. | |
Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python2 | |
Found possible Python library paths: | |
/usr/lib/python2.7/site-packages | |
/usr/local/lib/python3.7/site-packages | |
Please input the desired Python library path to use. Default is [/usr/lib/python2.7/site-packages] | |
Do you wish to build TensorFlow with jemalloc as malloc support? [Y/n]: n | |
No jemalloc as malloc support will be enabled for TensorFlow. | |
Do you wish to build TensorFlow with Google Cloud Platform support? [Y/n]: n | |
No Google Cloud Platform support will be enabled for TensorFlow. | |
Do you wish to build TensorFlow with Hadoop File System support? [Y/n]: n | |
No Hadoop File System support will be enabled for TensorFlow. | |
Do you wish to build TensorFlow with Amazon S3 File System support? [Y/n]: n | |
No Amazon S3 File System support will be enabled for TensorFlow. | |
Do you wish to build TensorFlow with XLA JIT support? [y/N]: n | |
No XLA JIT support will be enabled for TensorFlow. | |
Do you wish to build TensorFlow with GDR support? [y/N]: n | |
No GDR support will be enabled for TensorFlow. | |
Do you wish to build TensorFlow with VERBS support? [y/N]: n | |
No VERBS support will be enabled for TensorFlow. | |
Do you wish to build TensorFlow with OpenCL support? [y/N]: n | |
No OpenCL support will be enabled for TensorFlow. | |
Do you wish to build TensorFlow with CUDA support? [y/N]: y | |
CUDA support will be enabled for TensorFlow. | |
Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to default to CUDA 8.0]: 10.1 | |
Please specify the location where CUDA 10.1 toolkit is installed. Refer to README.md for more details. [Default is /opt/cuda]: | |
Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 6.0]: 7.5.1 | |
Please specify the location where cuDNN 7.5.1 library is installed. Refer to README.md for more details. [Default is /opt/cuda]: | |
Please specify a list of comma-separated Cuda compute capabilities you want to build with. | |
You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus. | |
Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 6.1] | |
Do you want to use clang as CUDA compiler? [y/N]: | |
nvcc will be used as CUDA compiler. | |
Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]: | |
Do you wish to build TensorFlow with MPI support? [y/N]: | |
No MPI support will be enabled for TensorFlow. | |
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]: | |
Add "--config=mkl" to your bazel command to build with MKL support. | |
Please note that MKL on MacOS or windows is still not supported. | |
If you would like to use a local MKL instead of downloading, please set the environment variable "TF_MKL_ROOT" every time before build. | |
Configuration finished | |
$ # Fix CUDA version mismatch | |
$ sudo ln -s $CUDA_HOME/include/crt/math_functions.hpp $CUDA_HOME/include/ | |
$ # Add patch for protocol-buffer as following for CUDA>=10. | |
``` | |
diff --git a/third_party/protobuf/add_noinlines.patch b/third_party/protobuf/add_noinlines.patch | |
index af74798f06..c1a06ded6d 100644 | |
--- a/third_party/protobuf/add_noinlines.patch | |
+++ b/third_party/protobuf/add_noinlines.patch | |
@@ -28,3 +28,39 @@ diff -u -r a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/ | |
" static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n" | |
" ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);\n" | |
"}\n"); | |
+ | |
+diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h | |
+index 40f35e92..1af91f9c 100644 | |
+--- a/src/google/protobuf/map.h | |
++++ b/src/google/protobuf/map.h | |
+@@ -425,10 +425,10 @@ class Map { | |
+ node_ = NULL; | |
+ for (bucket_index_ = start_bucket; bucket_index_ < m_->num_buckets_; | |
+ bucket_index_++) { | |
+- if (m_->TableEntryIsNonEmptyList(bucket_index_)) { | |
++ if ((*m_).TableEntryIsNonEmptyList(bucket_index_)) { | |
+ node_ = static_cast<Node*>(m_->table_[bucket_index_]); | |
+ break; | |
+- } else if (m_->TableEntryIsTree(bucket_index_)) { | |
++ } else if ((*m_).TableEntryIsTree(bucket_index_)) { | |
+ Tree* tree = static_cast<Tree*>(m_->table_[bucket_index_]); | |
+ GOOGLE_DCHECK(!tree->empty()); | |
+ node_ = NodePtrFromKeyPtr(*tree->begin()); | |
+@@ -487,7 +487,7 @@ class Map { | |
+ return true; | |
+ // Less common: the bucket is a linked list with node_ somewhere in it, | |
+ // but not at the head. | |
+- if (m_->TableEntryIsNonEmptyList(bucket_index_)) { | |
++ if ((*m_).TableEntryIsNonEmptyList(bucket_index_)) { | |
+ Node* l = static_cast<Node*>(m_->table_[bucket_index_]); | |
+ while ((l = l->next) != NULL) { | |
+ if (l == node_) { | |
+@@ -501,7 +501,7 @@ class Map { | |
+ // find-like method that compares Node* instead of const Key&. | |
+ iterator_base i(m_->find(*KeyPtrFromNodePtr(node_), it)); | |
+ bucket_index_ = i.bucket_index_; | |
+- return m_->TableEntryIsList(bucket_index_); | |
++ return (*m_).TableEntryIsList(bucket_index_); | |
+ } | |
+ | |
+ Node* node_; | |
``` | |
$ # Fix for cuda compiler compatibility (TODO) | |
``` | |
diff --git a/tensorflow/core/kernels/reduction_gpu_kernels.cu.h b/tensorflow/core/kernels/reduction_gpu_kernels.cu.h | |
index be9a611881..cda46570bf 100644 | |
--- a/tensorflow/core/kernels/reduction_gpu_kernels.cu.h | |
+++ b/tensorflow/core/kernels/reduction_gpu_kernels.cu.h | |
@@ -268,7 +268,8 @@ __global__ void ColumnReduceMax16ColumnsKernel( | |
// 1D array necessary due to bug in CUDA 9 compiler. | |
// TODO(nluehr) revert to 2D array when compiler is ready. | |
- __shared__ value_type partial_sums[32 * 33]; | |
+ value_type partial_sums[32 * 33]; | |
+ // __shared__ value_type partial_sums[32 * 33]; | |
row += rows_per_warp * gridDim.y * blockDim.y; | |
for (; row < num_rows; row += rows_per_warp * gridDim.y * blockDim.y) { | |
@@ -317,7 +318,8 @@ __global__ void ColumnReduceKernel( | |
// 1D array necessary due to bug in CUDA 9 compiler. | |
// TODO(nluehr) revert to 2D array when compiler is ready. | |
- __shared__ value_type partial_sums[32 * 33]; | |
+ value_type partial_sums[32 * 33]; | |
+ // __shared__ value_type partial_sums[32 * 33]; | |
row += gridDim.y * blockDim.y; | |
``` | |
$ bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package | |
$ ./bazel-bin/tensorflow/tools/pip_package/build_pip_package $PWD/tensorflow_pkg | |
$ sudo pip2 install tensorflow_pkg/tensorflow-1.4.2-cp27-cp27mu-linux_x86_64.whl | |
$ bazel build --config opt --config=cuda --copt=-march=native tensorflow:libtensorflow.so | |
$ git clone https://github.com/pmh47/dirt.git | |
$ cd dirt | |
$ # Change tensorflow path | |
``` | |
diff --git a/csrc/CMakeLists.txt b/csrc/CMakeLists.txt | |
index e69ba8d..82305c4 100644 | |
--- a/csrc/CMakeLists.txt | |
+++ b/csrc/CMakeLists.txt | |
@@ -12,14 +12,17 @@ find_library(EGL_LIBRARIES NAMES egl EGL REQUIRED) | |
get_filename_component(NVCC_DIR ${CMAKE_CUDA_COMPILER} DIRECTORY) | |
find_path(CUDA_INCLUDE_DIR NAMES cuda/include/cuda.h HINTS ${NVCC_DIR}/../.. PATHS ENV CUDA_HOME REQUIRED) | |
-# Ask tensorflow for its include path; one should therefore make sure cmake is run with the venv active that the op will be used in | |
-execute_process(COMMAND python -c "import tensorflow; print(tensorflow.sysconfig.get_include())" OUTPUT_VARIABLE Tensorflow_default_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE) | |
-set(Tensorflow_INCLUDE_DIRS "${Tensorflow_default_INCLUDE_DIRS}" CACHE PATH "Tensorflow include path") | |
- | |
-# Ask tensorflow for its library path | |
-# If using tensorflow earlier than v1.4, this will not work, but can be skipped entirely | |
-execute_process(COMMAND python -c "import tensorflow; print(tensorflow.sysconfig.get_lib())" OUTPUT_VARIABLE Tensorflow_default_LIB_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) | |
-set(Tensorflow_LIB_DIR "${Tensorflow_default_LIB_DIR}" CACHE PATH "Tensorflow library path") | |
+set(Tensorflow_INCLUDE_DIRS /usr/lib/python2.7/site-packages/tensorflow/include) | |
+set(Tensorflow_LIB_DIR /home/takiyu/Projects/work/huawei/dirt/tensorflow/bazel-bin/tensorflow/) | |
+ | |
+# # Ask tensorflow for its include path; one should therefore make sure cmake is run with the venv active that the op will be used in | |
+# execute_process(COMMAND python -c "import tensorflow; print(tensorflow.sysconfig.get_include())" OUTPUT_VARIABLE Tensorflow_default_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE) | |
+# set(Tensorflow_INCLUDE_DIRS "${Tensorflow_default_INCLUDE_DIRS}" CACHE PATH "Tensorflow include path") | |
+# | |
+# # Ask tensorflow for its library path | |
+# # If using tensorflow earlier than v1.4, this will not work, but can be skipped entirely | |
+# execute_process(COMMAND python2 -c "import tensorflow; print(tensorflow.sysconfig.get_lib())" OUTPUT_VARIABLE Tensorflow_default_LIB_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) | |
+# set(Tensorflow_LIB_DIR "${Tensorflow_default_LIB_DIR}" CACHE PATH "Tensorflow library path") | |
find_library(Tensorflow_LIBRARY tensorflow_framework HINTS ${Tensorflow_LIB_DIR} REQUIRED DOC "Tensorflow framework library; for tensorflow < 1.4, you can set this to blank") | |
# in the following, we need ../external/tensorflow for cuda_config.h in tf versions with #16959 unfixed | |
diff --git a/setup.py b/setup.py | |
index 568c5c4..1957645 100644 | |
--- a/setup.py | |
+++ b/setup.py | |
@@ -34,7 +34,7 @@ setup( | |
url='https://github.com/pmh47/dirt', | |
packages=['dirt'], | |
python_requires='>=2.7.0', | |
- install_requires=['tensorflow-gpu>=1.4', 'numpy'], | |
+ install_requires=[], | |
package_data={'dirt': ['*.so', '*.dll']}, | |
include_package_data=True, | |
cmdclass={'build': CmakeAndBuild}, | |
: | |
ensorflow_default_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE) | |
+# set(Tensorflow_INCLUDE_DIRS "${Tensorflow_default_INCLUDE_DIRS}" CACHE PATH "Tensorflow include path") | |
+# | |
+# # Ask tensorflow for its library path | |
+# # If using tensorflow earlier than v1.4, this will not work, but can be skipped entirely | |
+# execute_process(COMMAND python2 -c "import tensorflow; print(tensorflow.sysconfig.get_lib())" OUTPUT_VARIABLE Tensorflow_default_LIB_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) | |
+# set(Tensorflow_LIB_DIR "${Tensorflow_default_LIB_DIR}" CACHE PATH "Tensorflow library path") | |
find_library(Tensorflow_LIBRARY tensorflow_framework HINTS ${Tensorflow_LIB_DIR} REQUIRED DOC "Tensorflow framework library; for tensorflow < 1.4, you can set this to blank") | |
# in the following, we need ../external/tensorflow for cuda_config.h in tf versions with #16959 unfixed | |
diff --git a/setup.py b/setup.py | |
index 568c5c4..1957645 100644 | |
--- a/setup.py | |
+++ b/setup.py | |
@@ -34,7 +34,7 @@ setup( | |
url='https://github.com/pmh47/dirt', | |
packages=['dirt'], | |
python_requires='>=2.7.0', | |
- install_requires=['tensorflow-gpu>=1.4', 'numpy'], | |
+ install_requires=[], | |
package_data={'dirt': ['*.so', '*.dll']}, | |
include_package_data=True, | |
cmdclass={'build': CmakeAndBuild}, | |
~ | |
``` | |
$ pip2 install . | |
$ python2 | |
Python 2.7.16 (default, Mar 11 2019, 18:59:25) | |
[GCC 8.2.1 20181127] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import dirt | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment