Ubuntu 14.04 + CUDA 6.5 Sample Code

I am trying to get the sample projects to run on the following setup:
OS: Ubuntu 14.04
CUDA: 6.5
Driver: 340.29
GPU: GeForce 560gtx

The driver was bundled with CUDA, though I have also tried with the latest version.
I’ve installed the required dependencies and I am able to build the projects without any errors.

When I run any sample project with a graphical output I get a segmentation fault. eg:
$ ./oceanFFT
[CUDA FFT Ocean Simulation]

Left mouse button - rotate
Middle mouse button - pan
Right mouse button - zoom
‘w’ key - toggle wireframe
[CUDA FFT Ocean Simulation]
Segmentation fault (core dumped)

What can I try to resolve the problem?

By using GDB I was able to identify the function responsible for the issue.
It seems that it is to do with OpenGL/CUDA integration. The CUDA samples do not play nicely with the following environment variable setting:
export __GL_THREADED_OPTIMIZATIONS=1

I had previously introduced this into a /etc/profile.d/ startup script while solving a separate issues to do with tearing.

After commenting out this line the CUDA sample programs work correctly.