cudaMemcpyToSymbol returns "invalid device symbol" problem with __constant__ memory (Linux

I have defined a constant variable at file scope:

device constant float d_C_sqrt_2pi;

and I attempt to write its value into device memory from the host code:

float C_sqrt_2pi_ = …;

err = cudaMemcpyToSymbol(&d_C_sqrt_2pi, &C_sqrt_2pi_, sizeof(float), 0, cudaMemcpyHostToDevice);
if (err != cudaSuccess)
{
// print message
}

This consistently returns the error “invalid device symbol”. I tried the relevant solutions in the following post (where it was suggested but not confirmed that this is a Cuda bug):

http://forums.nvidia.com/index.php?showtopic=154504

but none of the suggestions helped. Do I need to cudaMalloc() the constant? Any idea what I’m doing wrong?

I am using a GeForce 480 card on

x86_64 Red Hat Enterprise Linux Client release 5.4 (Tikanga)

Nvidia driver version 256.40

The Cuda toolkit I downloaded was cudatoolkit_3.1_linux_64_rhel5.4.run

try

cudaMemcpyToSymbol("d_C_sqrt_2pi", &C_sqrt_2pi_, sizeof(float), 0, cudaMemcpyHostToDevice);

try

cudaMemcpyToSymbol("d_C_sqrt_2pi", &C_sqrt_2pi_, sizeof(float), 0, cudaMemcpyHostToDevice);

Thanks, that fixed the problem. The examples in the CUDA C Programming Guide 3.1.1, end of section 3.2.1 (Device Memory) seem to be in error.

Thanks, that fixed the problem. The examples in the CUDA C Programming Guide 3.1.1, end of section 3.2.1 (Device Memory) seem to be in error.