ftdlyc / KCNet_Pytorch

Partial implemention of KCNet
21 stars 6 forks source link

you provide the batch_nn.cu?how to compile this ? #2

Open AmyWan opened 5 years ago

AmyWan commented 5 years ago

Did u have the scripts?

ftdlyc commented 5 years ago

You can see the file utils/kcnet_utils.py#7
The c++/cuda code will auto compile when running using the cpp_extension tool in pytorch 0.4. I do not test whether this tool is still included in pytorch 1.0 version.
Or you can complie it explicitly and load the lib by python imp module (see https://github.com/ftdlyc/splatnet_pytorch/blob/master/utils/permutohedral_lattice_layer.py). To compile c++/cuda code you can use CMake. CMakeLists.txt script can be:

cmake_minimum_required(VERSION`` 2.8 FATAL_ERROR)
project($(project name) LANGUAGES CXX CUDA)
set(CMAKE_CXX_COMPILER "g++")
set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_CUDA_FLAGS "-std=c++11 --gpu-architecture=sm_61")
set(INCLUDE_DIRS
"/usr/local/cuda-8.0/include"
"$(your python path)/python3.5/site-packages/torch/lib/include"
"$(your python path)/python3.5/site-packages/torch/lib/include/TH"
"$(your python path)/python3.5/site-packages/torch/lib/include/THC"
"$(your python path)/include/python3.5m"
"${PROJECT_SOURCE_DIR}/utils/include")
include_directories(${INCLUDE_DIRS})
add_library($(lib name) SHARED $(code path)/xxxx.cu $(code path)/xxxx.cc)

replace $(project name) $(your python path) $(lib name) $(code path)

linhaojia13 commented 5 years ago

When I run the script, it shows: Traceback (most recent call last): File "/home/ubuntu/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 949, in _build_extension_module check=True) File "/home/ubuntu/anaconda3/envs/pytorch/lib/python3.7/subprocess.py", line 487, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

I think it may be caused by the mismatch of the gcc, cuda versions, could you tell me your gcc, cuda and linux version?