Cuda 安装Nvidia Optix SDK 3.0.0 Ubuntu 12.04

Cuda 安装Nvidia Optix SDK 3.0.0 Ubuntu 12.04,cuda,ubuntu-12.04,nvidia,optix,Cuda,Ubuntu 12.04,Nvidia,Optix,您好,我正在尝试在Ubuntu上安装nVidia OptiX SDK版本3.0.0 für linux64 我已经下载了.run文件。执行完成后,我得到一个名为~/NVIDIA-OptiX-SDK-3.0.0-linux64的文件夹/ 它在我的主文件夹中 预编译的示例工作得很好,但当我尝试编译自己的代码时,编译器似乎将.cu文件作为CUDA文件处理,并尝试将它们编译为.cu.o。 我的程序错误的一个输出是: Building NVCC (Device) object CMakeFiles/Ray

您好,我正在尝试在Ubuntu上安装nVidia OptiX SDK版本3.0.0 für linux64

我已经下载了.run文件。执行完成后,我得到一个名为~/NVIDIA-OptiX-SDK-3.0.0-linux64的文件夹/

它在我的主文件夹中

预编译的示例工作得很好,但当我尝试编译自己的代码时,编译器似乎将.cu文件作为CUDA文件处理,并尝试将它们编译为.cu.o。 我的程序错误的一个输出是:

Building NVCC (Device) object CMakeFiles/RayTracerExec.dir/src/Tracy/ObjectLoader/optixcu/./RayTracerExec_generated_triangle_mesh_target.cu.o
通常这些文件应该编译成某种ptx文件

错误如下:

ptxas /tmp/tmpxft_00000eef_00000000-5_triangle_mesh_target.ptx, line 94; error   : Label expected for argument 0 of instruction 'call'
ptxas /tmp/tmpxft_00000eef_00000000-5_triangle_mesh_target.ptx, line 94; error   : Call target not recognized
ptxas /tmp/tmpxft_00000eef_00000000-5_triangle_mesh_target.ptx, line 94; error   : Function '_rt_buffer_get_64' not declared in this scope
没有找到函数
\u rt\u buffer\u get\u 64
,这让我觉得有些东西安装不正确

文件夹中有名为的子文件夹 doc include lib64 SDK预编译示例 我所做的是将include的内容复制到/usr/local/include中 并将lib64的内容转换为/usr/local/lib

有什么想法吗?
关于

从输出中的文本判断,您似乎正在使用CMake构建示例。看起来构建系统认为您需要编译对象文件而不是PTX文件。您看到的错误消息也表明此症状

有几种方法可以从CMake中编译CUDA代码

如果您正在使用CUDA运行时,则通常会执行以下操作:

cuda_add_executable(myprogram main.cpp mycuda.cu myheader.h)
这将创建一个名为myprogram的可执行文件,该文件由两个对象文件组成:main.cpp.o和mycuda.cu.o。CUDA运行时希望CUDA文件中的代码符合CUDA运行时API

除了
cuda\u add\u可执行文件
之外,还有
cuda\u add\u库
,它编译库而不是可执行文件。这两个宏都使用另一个名为
cuda\u wrap\u srcs
的宏,该宏完成了大部分繁重的工作,可以生成编译cuda代码的构建命令。除此之外,该宏还有一个参数,用于指定是要使用CUDA运行时还是只针对PTX(参数为OBJ或PTX)

为了让OptiX着色器编译,必须以PTX为目标。在我们的SDK中,这是通过一个名为
OPTIX\u add\u sample\u executable
的CMake函数来处理的,该函数可以在
/SDK/CMakeLists.txt
中找到。这个函数主要是调用
cuda\u wrap\u srcs
,并指定PTX选项。我在这里也包含了这个函数以供参考

#########################################################
# OPTIX_add_sample_executable
#
# Convenience function for adding samples to the code.  You can copy the contents of this
# function into your individual project if you wish to customize the behavior.  Note that
# in CMake, functions have their own scope, whereas macros use the scope of the caller.
function(OPTIX_add_sample_executable target_name)

  # These calls will group PTX and CUDA files into their own directories in the Visual
  # Studio projects.
  source_group("PTX Files"  REGULAR_EXPRESSION ".+\\.ptx$")
  source_group("CUDA Files" REGULAR_EXPRESSION ".+\\.cu$")

  # Separate the sources from the CMake and CUDA options fed to the macro.  This code
  # comes from the CUDA_COMPILE_PTX macro found in FindCUDA.cmake.  We are copying the
  # code here, so that we can use our own name for the target.  target_name is used in the
  # creation of the output file names, and we want this to be unique for each target in
  # the SDK.
  CUDA_GET_SOURCES_AND_OPTIONS(source_files cmake_options options ${ARGN})

  # Create the rules to build the PTX from the CUDA files.
  CUDA_WRAP_SRCS( ${target_name} PTX generated_files ${source_files} ${cmake_options}
    OPTIONS ${options} )

  # Here is where we create the rule to make the executable.  We define a target name and
  # list all the source files used to create the target.  In addition we also pass along
  # the cmake_options parsed out of the arguments.
  add_executable(${target_name}
    ${source_files}
    ${generated_files}
    ${cmake_options}
    )

  # Most of the samples link against the sutil library and the optix library.  Here is the
  # rule that specifies this linkage.
  target_link_libraries( ${target_name}
    sutil
    optix
    ${optix_rpath}
    )
endfunction()

从输出中的文本判断,您似乎正在使用CMake构建示例。看起来构建系统认为您需要编译对象文件而不是PTX文件。您看到的错误消息也表明此症状

有几种方法可以从CMake中编译CUDA代码

如果您正在使用CUDA运行时,则通常会执行以下操作:

cuda_add_executable(myprogram main.cpp mycuda.cu myheader.h)
这将创建一个名为myprogram的可执行文件,该文件由两个对象文件组成:main.cpp.o和mycuda.cu.o。CUDA运行时希望CUDA文件中的代码符合CUDA运行时API

除了
cuda\u add\u可执行文件
之外,还有
cuda\u add\u库
,它编译库而不是可执行文件。这两个宏都使用另一个名为
cuda\u wrap\u srcs
的宏,该宏完成了大部分繁重的工作,可以生成编译cuda代码的构建命令。除此之外,该宏还有一个参数,用于指定是要使用CUDA运行时还是只针对PTX(参数为OBJ或PTX)

为了让OptiX着色器编译,必须以PTX为目标。在我们的SDK中,这是通过一个名为
OPTIX\u add\u sample\u executable
的CMake函数来处理的,该函数可以在
/SDK/CMakeLists.txt
中找到。这个函数主要是调用
cuda\u wrap\u srcs
,并指定PTX选项。我在这里也包含了这个函数以供参考

#########################################################
# OPTIX_add_sample_executable
#
# Convenience function for adding samples to the code.  You can copy the contents of this
# function into your individual project if you wish to customize the behavior.  Note that
# in CMake, functions have their own scope, whereas macros use the scope of the caller.
function(OPTIX_add_sample_executable target_name)

  # These calls will group PTX and CUDA files into their own directories in the Visual
  # Studio projects.
  source_group("PTX Files"  REGULAR_EXPRESSION ".+\\.ptx$")
  source_group("CUDA Files" REGULAR_EXPRESSION ".+\\.cu$")

  # Separate the sources from the CMake and CUDA options fed to the macro.  This code
  # comes from the CUDA_COMPILE_PTX macro found in FindCUDA.cmake.  We are copying the
  # code here, so that we can use our own name for the target.  target_name is used in the
  # creation of the output file names, and we want this to be unique for each target in
  # the SDK.
  CUDA_GET_SOURCES_AND_OPTIONS(source_files cmake_options options ${ARGN})

  # Create the rules to build the PTX from the CUDA files.
  CUDA_WRAP_SRCS( ${target_name} PTX generated_files ${source_files} ${cmake_options}
    OPTIONS ${options} )

  # Here is where we create the rule to make the executable.  We define a target name and
  # list all the source files used to create the target.  In addition we also pass along
  # the cmake_options parsed out of the arguments.
  add_executable(${target_name}
    ${source_files}
    ${generated_files}
    ${cmake_options}
    )

  # Most of the samples link against the sutil library and the optix library.  Here is the
  # rule that specifies this linkage.
  target_link_libraries( ${target_name}
    sutil
    optix
    ${optix_rpath}
    )
endfunction()