CUDA does not recognize GPU after successfull use

Hi,

The problem that I have is that CUDA 8.0 with driver version 384.59 works fine in Ubuntu 16.04. It often happens that when I boot my laptop or recover the laptop from sleep that CUDA itself does not recognize my GPU anymore (while nvidia-smi clearly still recognizes my GPU).

Devicequery returns cudaGetDeviceCount return 30.

If I do a re-install of the nvidia driver it all seems to work again, until the next time this happens.

My output in nvidia-smi -q
==============NVSMI LOG==============

Timestamp : Tue Aug 15 10:43:23 2017
Driver Version : 384.59

Attached GPUs : 1
GPU 00000000:01:00.0
Product Name : GeForce GTX 950M
Product Brand : GeForce
Display Mode : Disabled
Display Active : Disabled
Persistence Mode : Enabled
Accounting Mode : Disabled
Accounting Mode Buffer Size : 1920
Driver Model
Current : N/A
Pending : N/A
Serial Number : N/A
GPU UUID : GPU-55958e4a-6617-b204-1617-19a4906de32b
Minor Number : 0
VBIOS Version : 82.07.8E.00.0D
MultiGPU Board : No
Board ID : 0x100
GPU Part Number : N/A
Inforom Version
Image Version : N/A
OEM Object : N/A
ECC Object : N/A
Power Management Object : N/A
GPU Operation Mode
Current : N/A
Pending : N/A
GPU Virtualization Mode
Virtualization mode : None
PCI
Bus : 0x01
Device : 0x00
Domain : 0x0000
Device Id : 0x139A10DE
Bus Id : 00000000:01:00.0
Sub System Id : 0x380B17AA
GPU Link Info
PCIe Generation
Max : 3
Current : 1
Link Width
Max : 16x
Current : 8x
Bridge Chip
Type : N/A
Firmware : N/A
Replays since reset : 0
Tx Throughput : 0 KB/s
Rx Throughput : 0 KB/s
Fan Speed : N/A
Performance State : P8
Clocks Throttle Reasons
Idle : Active
Applications Clocks Setting : Not Active
SW Power Cap : Not Active
HW Slowdown : Not Active
Sync Boost : Not Active
FB Memory Usage
Total : 4044 MiB
Used : 11 MiB
Free : 4033 MiB
BAR1 Memory Usage
Total : 256 MiB
Used : 1 MiB
Free : 255 MiB
Compute Mode : Exclusive_Process
Utilization
Gpu : 0 %
Memory : 0 %
Encoder : 0 %
Decoder : 0 %
Encoder Stats
Active Sessions : 0
Average FPS : 0
Average Latency : 0
Ecc Mode
Current : N/A
Pending : N/A
ECC Errors
Volatile
Single Bit
Device Memory : N/A
Register File : N/A
L1 Cache : N/A
L2 Cache : N/A
Texture Memory : N/A
Texture Shared : N/A
CBU : N/A
Total : N/A
Double Bit
Device Memory : N/A
Register File : N/A
L1 Cache : N/A
L2 Cache : N/A
Texture Memory : N/A
Texture Shared : N/A
CBU : N/A
Total : N/A
Aggregate
Single Bit
Device Memory : N/A
Register File : N/A
L1 Cache : N/A
L2 Cache : N/A
Texture Memory : N/A
Texture Shared : N/A
CBU : N/A
Total : N/A
Double Bit
Device Memory : N/A
Register File : N/A
L1 Cache : N/A
L2 Cache : N/A
Texture Memory : N/A
Texture Shared : N/A
CBU : N/A
Total : N/A
Retired Pages
Single Bit ECC : N/A
Double Bit ECC : N/A
Pending : N/A
Temperature
GPU Current Temp : 35 C
GPU Shutdown Temp : 101 C
GPU Slowdown Temp : 96 C
Memory Temp : N/A
Power Readings
Power Management : N/A
Power Draw : N/A
Power Limit : N/A
Default Power Limit : N/A
Enforced Power Limit : N/A
Min Power Limit : N/A
Max Power Limit : N/A
Clocks
Graphics : 135 MHz
SM : 135 MHz
Memory : 405 MHz
Video : 405 MHz
Applications Clocks
Graphics : 993 MHz
Memory : 1001 MHz
Default Applications Clocks
Graphics : 993 MHz
Memory : 1001 MHz
Max Clocks
Graphics : 1124 MHz
SM : 1124 MHz
Memory : 1001 MHz
Video : 1011 MHz
Max Customer Boost Clocks
Graphics : N/A
Clock Policy
Auto Boost : N/A
Auto Boost Default : N/A
Processes : None

Please help what I can do to set it up in such a way that I do not have to reinstall the drivers every couple of days.