Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

CUDA invalid device symbol error on cudaMemcpyToSymbol

📅 2013-Jan-29 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cuda, error ⬩ 📚 Archive


In your CUDA code, you have a cudaMemcpyToSymbol call of this form:

cudaMemcpyToSymbol( "deviceVar", hostVar, hostVarSize, 0, cudaMemcpyHostToDevice );

This gives a runtime error of invalid device symbol.


Check if you are using CUDA 5.0 or later. The technique of passing the device symbol by using its name string is gone in CUDA 5.0. Instead, just remove the double quotes to specify the device variable itself like this:

cudaMemcpyToSymbol( deviceVar, &hostVar, hostVarSize, 0, cudaMemcpyHostToDevice );

Tried with: CUDA 5.0

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧