luanfujun/deep-photo-styletransfer

Issue regarding compiling cuda_utils.cu

Closed this issue ยท 4 comments

When I try to compile cuda_utils.cu, I get this message:

sacha@scriabin:~/deep-photo-styletransfer-master$ make clean && make

find . -type f | xargs -n 5 touch
rm -f libcuda_utils.so
/usr/local/cuda-8.0/bin/nvcc -arch sm_35 -O3 -DNDEBUG --compiler-options '-fPIC' -o libcuda_utils.so --shared cuda_utils.cu -I/home/torch/install/include/THC -I/home/torch/install/include/TH -I/home/torch/install/include -L/home/torch/install/lib -Xlinker -rpath,/home/torch/install/lib -lluaT -lTHC -lTH -lpng
cuda_utils.cu:2:18: fatal error: lua.h: No such file or directory
#include "lua.h"
^
compilation terminated.
make: *** [libcuda_utils.so] Error 1

I changed my makefile to the following:

PREFIX=/home/torch/install
NVCC_PREFIX=/usr/local/cuda-8.0/bin

lua.h, lualib.h and lauxlib.h are all in the same folder: /home/torch/install/include.

I already tried to add -lluajit like proposed in #5 and 21 - doesn't work either.

I'm on Ubuntu 14.04.5 LTS, and after a long reading everything before worked just fine (that wasn't the case with my first shot in another computer, now I'm being way more careful about each step). I kept track of all the command lines I used and the files I downloaded if required. The luarocks I used was the one within torch.

Thanks for your help!

That's odd. Do your make settings look like this? Please note that i use OSX, but it shouldn't matter for this advice.

PREFIX=/<path-to-your-user-folder>/torch/install
(...)
CFLAGS=-I$(PREFIX)/include/THC -I$(PREFIX)/include/TH -I$(PREFIX)/include -I/usr/local/include
LDFLAGS_NVCC=-L$(PREFIX)/lib -Xlinker -rpath,$(PREFIX)/lib -lluaT -lTHC -lTH -lpng -lluajit
(...)

libcuda_utils.so: cuda_utils.cu
	$(NVCC_PREFIX)/nvcc -arch sm_35 -O3 -DNDEBUG --compiler-options '-fPIC' '-I/Users/<your-username>/torch/install/include -c src/lfs.c' -o libcuda_utils.so --shared cuda_utils.cu $(CFLAGS) $(LDFLAGS_NVCC)
(...)

Changes compared to the original makefile:

Please note that i've added
'-I/<path-to-your-user-folder>/torch/install/include -c src/lfs.c'
after '-fPIC' @ line 10.

Another change:
I've added -I/usr/local/include at the end of CFLAGS which is probably not necessary (but it doesn't hurt either).

The original makefile does not have this flag:
$(NVCC_PREFIX)/nvcc -arch sm_35 -O3 -DNDEBUG --compiler-options '-fPIC' -o libcuda_utils.so --shared cuda_utils.cu $(CFLAGS) $(LDFLAGS_NVCC)

Maybe adding '-I/<path-to-your-user-folder>/torch/install/include' helps the compiler to find lua.h, since it's usually under <user-path>/torch/install/include


On Ubuntu, shouldn't your user folder path look like this: /home/<your-username>/?

The /home/username directory is often referred to as just "the home directory".
From: https://help.ubuntu.com/community/HomeFolder

So maybe PREFIX should be changed from
/home/torch/install to
/home/<your-username>/torch/install

I'm probably totally wrong with this โ€“ so please go easy on me, i have no idea about Ubuntu ๐Ÿ˜ฌ.
If your torch install is just in /home/torch/install instead of /home/<your-username>/torch/install then please ignore this suggestion.

Oh... hem... well... ๐Ÿ˜“
That was this indeed... /home/sacha instead of just /home...
In my defense, I was only seeing /home...
(I feel bad now)
Thanks a lot!!! ๐Ÿ˜˜

screenshot from 2017-04-01 00 10 31

Haha ๐Ÿ˜ โ€“ the last time i've tried Ubuntu was 5 years ago. It seems that i still remember some things :-). Glad it works now!

I'm Ubuntu16.04LTS, and I`ve got a problem like this:

. -type f | xargs -n 5 touch
rm -f libcuda_utils.so
/usr/local/cuda-8.0/bin/nvcc -arch sm_35 -O3 -DNDEBUG --compiler-options '-fPIC' -o libcuda_utils.so --shared cuda_utils.cu -I/home/leo/torch/install/include/THC -I/home/leo/torch/install/include/TH -I/home/leo/torch/install/include -L/home/leo/torch/install/lib -Xlinker -rpath,/home/leo/torch/install/lib -lluaT -lTHC -lTH -lpng
cuda_utils.cu:8:17: fatal error: THC.h: No such file or directory
compilation terminated.
makefile:10: recipe for target 'libcuda_utils.so' failed
make: *** [libcuda_utils.so] Error 1

so What should i do?