fyu / drn

Dilated Residual Networks
https://www.vis.xyz/pub/drn
BSD 3-Clause "New" or "Revised" License
1.1k stars 219 forks source link

How to build lib folder for pytorch from scratch #33

Open skrya opened 6 years ago

skrya commented 6 years ago

When I have tried using the Makefile. I get the following error :

src/batchnormp_cuda_kernel.cu:1:20: fatal error: THCUNN.h: No such file or directory compilation terminated. Makefile:33: recipe for target 'dense/batchnormp_kernel.so' failed make: *** [dense/batchnormp_kernel.so] Error 1

Here is the Make file PYTORCH_LIB_DIR := /users/sudhirkumar/fcn/py3_pytorch0.4/lib/python3.5/site-packages/torch/lib

PYTHON := python3 NVCC_COMPILE := nvcc -c -o RM_RF := rm -rf

Library compilation rules.

NVCC_FLAGS := -x cu -Xcompiler -fPIC -shared

File structure.

BUILD_DIR := dense INCLUDE_DIRS := TH THC THCUNN include include/TH TORCH_FFI_BUILD := build.py BN_KERNEL := $(BUILD_DIR)/batchnormp_kernel.so TORCH_FFI_TARGET := $(BUILD_DIR)/batch_norm/_batch_norm.so

INCLUDE_FLAGS := $(foreach d, $(INCLUDE_DIRS), -I$(PYTORCH_LIB_DIR)/$d)

INCLUDE_FLAGS2 := $(foreach d, $(INCLUDE_DIRS), -I$(PYTORCH_LIB_DIR2)/$d)

INCLUDE_FLAGS3 := $(foreach d, $(INCLUDE_DIRS), -I$(PYTORCH_LIB_DIR3)/$d)

all: $(TORCH_FFI_TARGET)

$(TORCH_FFI_TARGET): $(BN_KERNEL) $(TORCH_FFI_BUILD) $(PYTHON) $(TORCH_FFI_BUILD)

$(BUILD_DIR)/batchnormp_kernel.so: src/batchnormp_cuda_kernel.cu @mkdir -p $(BUILD_DIR) $(NVCC_COMPILE) $@ $? $(NVCC_FLAGS) $(INCLUDE_FLAGS) -Isrc -std=c++11

clean: $(RM_RF) $(BUILD_DIR)

Thanks, Sudhir