编译cuda代码时遇到问题

发布于 2024-12-02 03:10:47 字数 3535 浏览 0 评论 0原文

我想编译这个体积渲染项目。我在 Ubuntu 10.10 计算机上安装了 CUDA 工具包和 SDK,并且能够运行其示例,但我得到了这个:

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

我该如何解决这个问题?


编辑:当在 vfRay.cu 文件上运行 talonmies 描述的步骤时,我得到:

  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.

新编辑: 好吧,当执行 -L 来包含我得到的 cutil.h 目录时这适用于 vfRay.cu 和 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".

我认为这是一个makefile问题,我怀疑这个编译在不修改它的情况下是否可以工作。

这是该项目的 makefile:

#
# Makefile CPU / CUDA
#

#-----------------------------------------------------------------------------

all:    cpu cuda

cpu:        MakefileCPU
            make -f MakefileCPU

cuda:       MakefileCUDA
            make -f MakefileCUDA

clean:
            make -f MakefileCPU clean
            make -f MakefileCUDA clean

我制作了这个 mod,但不起作用:

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

编辑:我修改了 common.mk 文件,以便第 93 行指向 gcc 4.4,现在我得到了cutil 缺失错误。我可以在哪里修改它?我尝试将它放在 usr/bin 的 ld 文件夹中,但 ld 是一个程序,我无法删除它。

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

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
#

#-----------------------------------------------------------------------------

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画离情绘悲伤 2024-12-09 03:10:47

顾名思义,nvcc --compiler-bindir 将目录作为参数,而不是编译器可执行文件本身。为了以这种方式使用替代编译器,您需要传递一个目录,其中包含一个名为 gcc 的可执行文件,或者一个名为 gcc 的链接,该链接指向 gcc 的有效版本。最简单的方法是创建一个定位目录,其中包含指向受支持的编译器版本的符号链接。像这样的东西:

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]

编辑1:

在您尝试构建的代码中,您需要编辑文件common.mk,第 93 行 并将 --compiler-bindir 选项更改为您在某个位置设置的绝对路径,其中包含链接方式如图所示 多于。


编辑2:

您尝试编译的代码依赖于NVIDIA GPU计算SDK。您必须设置环境变量 ROOT_DIR 以指向 SDK 发行版内的 C 树,或者修改 与您尝试构建的代码一起提供的 common.mk 文件的第 50 行。您还必须确保已通过在 SDK 根目录的 C/common 目录中运行 make 来编译 cutil 库。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文