Not a bug.
This is because you enabled CUDA in your script but disabled CUDA in Python interactive shell.
In fact, CUDA is disabled by default unless you enable it explicitly.
So you must have enabled CUDA somewhere in your script code.