我controlling expression is constant在assert语句中收到警告,如下所示:
assert(... && "error message");
Run Code Online (Sandbox Code Playgroud)
为什么这个警告就这个断言?我怎么能压制这个警告?
NVCC是NVIDIA cuda编译器,我认为它基于LLVM.当GCC或Visual C++编译器编译好时,为什么会发出此警告?
问题:
有了.h,我想在编译c/c ++或者计算能力> = 1.3的cuda时将real定义为double.如果为计算能力<1.3的cuda进行编译,则将real定义为float.
几个小时后我来到这里(这不起作用)
# if defined(__CUDACC__) # warning * making definitions for cuda # if defined(__CUDA_ARCH__) # warning __CUDA_ARCH__ is defined # else # warning __CUDA_ARCH__ is NOT defined # endif # if (__CUDA_ARCH__ >= 130) # define real double # warning using double in cuda # elif (__CUDA_ARCH__ >= 0) # define real float # warning using float in cuda # warning how the hell is this printed when __CUDA_ARCH__ is not defined? # else …
如果我编译具有较低计算能力的CUDA程序,例如1.3(nvcc标志sm_13),并在具有计算能力2.1的设备上运行它,它是否会利用计算2.1的功能?
在那种情况下,计算2.1设备是否会像计算1.3设备一样运行?
我正在尝试将CUDA添加到90年代末期编写的现有单线程C程序中.
为此,我需要混合两种语言,C和C++(nvcc是一个c ++编译器).
问题是C++编译器将结构看作某个大小,而C编译看到的结构与稍微不同的大小相同.那很糟.我真的很困惑,因为我找不到4字节差异的原因.
/usr/lib/gcc/i586-suse-linux/4.3/../../../../i586-suse-linux/bin/ld: Warning: size of symbol `tree' changed from 324 in /tmp/ccvx8fpJ.o to 328 in gpu.o
Run Code Online (Sandbox Code Playgroud)
我的C++看起来像
#include <stdio.h>
#include <stdlib.h>
#include "assert.h"
extern "C"
{
#include "structInfo.h" //contains the structure declaration
}
...
Run Code Online (Sandbox Code Playgroud)
和我的C文件看起来像
#include "structInfo.h"
...
Run Code Online (Sandbox Code Playgroud)
与structInfo.h看起来像
struct TB {
int nbranch, nnode, root, branches[NBRANCH][2];
double lnL;
} tree;
...
Run Code Online (Sandbox Code Playgroud)
我的make文件看起来像
PRGS = prog
CC = cc
CFLAGS=-std=gnu99 -m32
CuCC = nvcc
CuFlags =-arch=sm_20
LIBS = -lm -L/usr/local/cuda-5.0/lib -lcuda -lcudart
all : $(PRGS)
prog:
$(CC) …Run Code Online (Sandbox Code Playgroud) 嗨,
我编译了一个CUDA共享库,但无法将其与使用它的主程序链接.我用gcc编译主程序.
代码:
simplemain.c
#include <stdio.h>
#include <stdlib.h>
void fcudadriver();
int main()
{
printf("Main \n");
fcudadriver();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
test.cu
__global__ void fcuda()
{
}
void fcudadriver()
{
fcuda<<<1,1>>>();
}
Run Code Online (Sandbox Code Playgroud)
我编译test.cu为 - >它的工作原理
nvcc --compiler-options '-fPIC' -o libtest.so --shared test.cu
Run Code Online (Sandbox Code Playgroud)
我编译simplemain.c为--->它给出错误:(
gcc simplemain.c -L. -ltest
/tmp/ccHnB4Vh.o:simplemain.c:function main: error: undefined reference to 'fcudadriver'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud) CUDA编译器可以选择生成32位或64位PTX.这些有什么区别?对于x86来说,NVidia GPU实际上有32位和64位ISA吗?或者它只与主机代码有关?
我想达到同样的效果
gcc -dM -E - < /dev/null
Run Code Online (Sandbox Code Playgroud)
(如此处所述) - 但对于 nvcc。也就是说,我想转储所有 nvcc 的预处理器定义。唉,nvcc 不支持-dM. 我该怎么办?
我正在设置python和theano用于gpu on; ubuntu 14.04,GeForce GTX 1080已经成功为系统安装了NVIDIA驱动程序(367.27)和CUDA工具包(7.5),但是在使用theano gpu实现进行测试时我得到了上述错误(例如;当导入带有gpu的theano时)我试过了寻找可能的解决方案,但没有成功.我对ubuntu和gpu编程有点新意,所以我很感激能够解决这个问题.谢谢
我正在尝试为需要使用支持 cuda 的编译器进行编译的虚拟类生成 python 绑定。我正在使用 cmake 3.12.0、pybind11 v2.2.3 和 nvcc 7.5.17。编译失败,因为 和 等选项-flto直接-fno-fat-lto-objects传递给 nvcc,而 nvcc 无法识别它们。
这是一个(最小)示例:
Cuda 代码:
//Adder.hpp
#include <thrust/host_vector.h>
struct Adder {
thrust::host_vector<float> a_h;
thrust::host_vector<float> b_h;
thrust::host_vector<float> r_h;
int N;
Adder(int N);
void set_a(float const * const in);
void set_b(float const * const in);
void calc();
void calc_gpu();
};
//Adder.cu
#include "Adder.hpp"
#include <thrust/device_vector.h>
Adder::Adder(int N): N(N),a_h(N),b_h(N),r_h(N) {}
void Adder::set_a(float const * const in) {
for (int i=0; i<N; ++i) {
a_h[i] = …Run Code Online (Sandbox Code Playgroud) 最近,一位同事需要使用NVML查询设备信息,因此我下载了Tesla开发工具包3.304.5,并将文件nvml.h复制到了/ usr / include。为了进行测试,我在tdk_3.304.5 / nvml / example中编译了示例代码,并且工作正常。
整个周末,系统中发生了某些更改(我无法确定更改的内容,而且我不是唯一有权访问计算机的更改),现在使用nvml.h的任何代码(例如示例代码)都会失败,并出现以下错误:
Failed to initialize NVML:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
WARNING:
You should always run with libnvidia-ml.so that is installed with your NVIDIA Display Driver. By default it's installed in /usr/lib and /usr/lib64. libnvidia-ml.so in TDK package is a stub library that is attached only for build purposes (e.g. machine that you build your application doesn't have to have Display Driver installed).
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Run Code Online (Sandbox Code Playgroud)
但是,我仍然可以运行nvidia-smi并读取有关我的K20m状态的信息,据我所知,nvidia-smi只是对nvml.h的一组调用。我收到的错误消息有些含糊,但我相信它告诉我nvidia-ml.so文件需要与我在系统上安装的Tesla驱动程序匹配。为了确保一切正确,我重新下载了CUDA 5.0并安装了驱动程序,CUDA运行时和测试文件。我确定nvidia-ml.so文件与驱动程序匹配(均为304.54),所以对于可能出了什么问题我感到很困惑。我可以使用nvcc编译和运行测试代码,也可以运行自己的CUDA代码,只要它不包含nvml.h。
有没有人遇到此错误或对纠正此问题有任何想法?
$ ls -la /usr/lib/libnvidia-ml*
lrwxrwxrwx. 1 root root 17 Jul …Run Code Online (Sandbox Code Playgroud)