Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Unload of CUDA runtime error with Thrust

📅 2013-Sep-29 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive


Your CUDA program that uses the Thrust library executes correctly, but at the end throws up this error:

terminate called after throwing an instance of 'thrust::system::system_error'
what():  unload of CUDA runtime failed


This cryptic error typically occurs if you are using Thrust device_vector in your program. I found that this error occurs when I have a device_vector which is destroyed after the CUDA runtime has been unloaded.

For example, this can happen if you have declared a vector as a global variable. At the end of the program, the CUDA runtime is unloaded. If the destructor of the vector is called after this, it cannot destroy fully since it needs the CUDA runtime. Moving these global vectors inside functions or classes might fix the error.

Tried with: CUDA 5 and Ubuntu 12.04 LTS