Add support for specifying CUDA C++ standard when compiling octree

This commit is contained in:
Paul Dinh 2020-12-18 21:51:05 +00:00 коммит произвёл wang-ps
Родитель af41d29066
Коммит 28283f98d7
3 изменённых файлов: 31 добавлений и 7 удалений

Просмотреть файл

@ -73,6 +73,19 @@ The code has been tested with Ubuntu 16.04/18.04 and TensorFlow 1.14.0/1.12.0.
```
3. Build the code under `tensorflow`.
<!-- =======
3. Build the code under `octree` with CUDA enabled.
```shell
cd octree/build
cmake .. -DUSE_CUDA=ON && make
# optionally, specify the CUDA/C++ standard when building
cmake .. -DUSE_CUDA=ON -DCMAKE_CUDA_STANDARD=14 && make
```
4. Build the code under `tensorflow`.
>>>>>>> 4dbfc73 (Add support for specifying CUDA C++ standard when compiling octree)
-->
```shell
cd tensorflow/libs
python build.py
@ -108,6 +121,9 @@ The code has been tested with Ubuntu 16.04 and PyTorch 1.6.0.
2. Build O-CNN under PyTorch.
```shell
python setup.py install --build_octree
# optionally, specify the CUDA/C++ standard when building with --cuda11 (default) or --cuda14
python setup.py install --build_octree --cuda14
```
3. Run the test cases.

Просмотреть файл

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8.2)
cmake_minimum_required(VERSION 3.10.3)
# options
option(USE_MINIBALL "Use the Miniball.hpp" ON)
@ -18,6 +18,7 @@ if(USE_CUDA)
message(STATUS "octree: USE_CUDA")
project(Octree LANGUAGES CUDA CXX C)
add_definitions(-DUSE_CUDA)
set (CMAKE_CUDA_STANDARD 11 CACHE STRING "CUDA CXX STANDARD")
else()
project(Octree LANGUAGES C CXX)
endif()

Просмотреть файл

@ -13,7 +13,7 @@ libraries = ['octree_lib', 'cublas']
if sys.platform == 'win32':
library_dirs[0] = os.path.join(library_dirs[0], 'Release')
def build_octree():
def build_octree(cuda_standard=11):
octree_ext = os.path.join(octree_dir, 'external/octree-ext')
if not os.path.exists(octree_ext):
url = 'https://github.com/wang-ps/octree-ext.git'
@ -26,16 +26,23 @@ def build_octree():
shutil.rmtree(octree_build, ignore_errors=True)
x64 = '-A x64' if sys.platform == 'win32' else ''
cmd = 'mkdir {} && cd {} && cmake .. -DABI=ON -DKEY64=ON {} && ' \
cmd = 'mkdir {} && cd {} && cmake .. -DABI=ON -DKEY64=ON {} -DCMAKE_CUDA_STANDARD={} && ' \
'cmake --build . --config Release && ./octree_test'.format(
octree_build, octree_build, x64)
octree_build, octree_build, x64, cuda_standard)
print(cmd)
os.system(cmd)
if "--build_octree" in sys.argv:
build_octree()
sys.argv.remove("--build_octree")
# default CUDA standard
cuda_standard = 11
supported_cuda_standards = ['--cuda11', '--cuda14']
for std in supported_cuda_standards:
if std in sys.argv:
cuda_standard = std.replace('--cuda', '')
sys.argv.remove(std)
break
build_octree(cuda_standard)
sys.argv.remove("--build_octree")
# builid ocnn
src = './cpp' # '{}/cpp'.format(curr_dir)