Trouble compiling cuda code
I want to compile this volume rendering project. I installed the CUDA toolkit and SDK on my Ubuntu 10.10 machine and have been able to run its examples, yet I'm getting this:
antonio@antonio-desktop:~/vfray$ make
make -f MakefileCPU
make[1]: Entering directory `/home/antonio/vfray'
make[1]: `vfRayCPU' is up to date.
make[1]: Leaving directory `/home/antonio/vfray'
make -f MakefileCUDA
make[1]: Entering directory `/home/antonio/vfray'
nvcc -o vfRay.cu_o -c vfRay.cu --ptxas-options=-v --compiler-bindir=/usr/bin/gcc-4.3 --compiler-options -fno-strict-aliasing -I. -I/usr/local/cuda/include -I/usr/local/cuda/SDK/C/common/inc -DUNIX -O3
/usr/bin/gcc-4.3: No such file or directory
make[1]: *** [vfRay.cu_o] Error 1
make[1]: Leaving directory `/home/antonio/vfray'
make: *** [cuda] Error 2
How can I fix this?
Edit: when running the steps described by talonmies on the vfRay.cu file I get:
antonio@antonio-desktop:~/vfray$ nvcc --compiler-bindir=./jdir -arch=sm_20 -c -Xptxas="-v" vfRay.cu
vfRay.cu:25: fatal error: cutil.h: No such file or directory
compilation terminated.
New Edit: alright, when doing -L to include the cutil.h directory I got this for vfRay.cu and vfRayKernel.cu.
antonio@antonio-desktop:~/vfray$ nvcc --compiler-bindir=./jdir -arch=sm_20 -c -Xptxas="-v" vfRay.cu -I/home/antonio/NVIDIA_GPU_Computing_SDK/C/common/inc/
vfRay.cu:48: fatal error: vfRayKernel.cu: No such file or directory
compilation terminated.
antonio@antonio-desktop:~/vfray$ nvcc --compiler-bindir=./jdir -arch=sm_20 -c -Xptxas="-v" vfRayKernel.cu -I/home/antonio/NVIDIA_GPU_Computing_SDK/C/common/inc/
vfRayKernel.cu(80): error: identifier "BLOCK_SIZE" is undefined
vfRayKernel.cu(181): error: identifier "BLOCK_SIZE" is undefined
vfRayKernel.cu(262): error: identifier "BLOCK_SIZE" is undefined
3 errors detected in the compilation of "/tmp/tmpxft_000064a5_00000000-4_vfRayKernel.cpp1.ii".
I think this is a makefile problem, I doubt this compilation will work without modifying it.
This is the makefile for the project:
#
# Makefile CPU / CUDA
#
#--------------开发者_C百科---------------------------------------------------------------
all: cpu cuda
cpu: MakefileCPU
make -f MakefileCPU
cuda: MakefileCUDA
make -f MakefileCUDA
clean:
make -f MakefileCPU clean
make -f MakefileCUDA clean
I made this mod and isn't working:
all: cpu cuda
cpu: MakefileCPU
make -f MakefileCPU
cuda: MakefileCUDA
make -f MakefileCUDA
nvcc --compiler-bindir=./jdir -arch=sm_20 -c -Xptxas="-v"
clean:
make -f MakefileCPU clean
make -f MakefileCUDA clean
Edit: I modified the common.mk file so that line 93 points to the gcc 4.4, now I'm getting the cutil missing error. Where can I modify that? I tried placing it inside a ld folder in usr/bin, but ld is a program and I can't erase it.
antonio@antonio-desktop:~/vfray$ make
make -f MakefileCPU
make[1]: Entering directory `/home/antonio/vfray'
make[1]: `vfRayCPU' is up to date.
make[1]: Leaving directory `/home/antonio/vfray'
make -f MakefileCUDA
make[1]: Entering directory `/home/antonio/vfray'
g++ -fPIC -o .///vfRay .///vfRayPreComp.o .///vfRay.cu_o -L/usr/local/cuda/lib64 -L/usr/local/cuda/SDK/C/lib -L/usr/local/cuda/SDK/C/common/lib -lcudart -lGL -lGLU -lglut -L/usr/local/cuda/lib64 -L/usr/local/cuda/SDK/C/lib -L/usr/local/cuda/SDK/C/common/lib -lcutil
/usr/bin/ld: cannot find -lcutil
collect2: ld returned 1 exit status
make[1]: *** [vfRay] Error 1
make[1]: Leaving directory `/home/antonio/vfray'
make: *** [cuda] Error 2
The nvcc --compiler-bindir
, as the name suggests, takes a directory as an argument, not the compiler executable itself. In order to use an alternative compiler in this way, you need to pass a directory which contains an either an executable called gcc, or a link called gcc which points to a valid version of gcc. The easiest way to do this is to create a locate directory containing a symbolic link to a supported compiler version. Something like this:
1. user@cuda:~$ mkdir jdir
2. user@cuda:~$ cd jdir
3. user@cuda:~/jdir$ ln -s /usr/bin/gcc-4.4 ./gcc
4. user@cuda:~$ ls -l jdir
total 0
lrwxrwxrwx 1 user user 12 2011-08-31 08:34 gcc -> /usr/bin/gcc-4.4
5. user@cuda:~/jdir$ cd ..
6. user@cuda:~$ nvcc --compiler-bindir=./jdir -arch=sm_20 -c -Xptxas="-v" particles3.cu
ptxas info : Compiling entry function '_Z6pointsP6float4f' for 'sm_20'
ptxas info : Function properties for _Z6pointsP6float4f
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Used 29 registers, 44 bytes cmem[0], 4 bytes cmem[14], 12 bytes cmem[16]
EDIT 1:
In the code you are trying build you need to edit the file common.mk, line 93 and change the --compiler-bindir
option to an absolute path which you set up somewhere containing links in the way demonstrated above.
EDIT 2:
The code you are trying to compile is relying on the NVIDIA GPU Computing SDK. You will have to either set an environment variable ROOT_DIR
to point to the C tree inside the SDK distribution or modify line 50 of the common.mk file that comes with the code you are trying to build. You will also have to ensure that the cutil library has been compiled by running make in the C/common directory of the SDK root.
精彩评论