CUDA 8 hangs on Windows 8.1

Hello.

CUDA 8 hangs on Windows 8.1 laptop with NVIDIA Optimus: display freezes.

NVIDIA Control Panel -> Manage 3D settings -> Global settings is set to Integrated graphics.

nvidia-smi output:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 376.51                 Driver Version: 376.51                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GT 640M    WDDM  | 0000:01:00.0     N/A |                  N/A |
| N/A   65C    P0    N/A /  N/A |    102MiB /  1024MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+

Driver is switched to WMD:

nvidia-smi -fdm 0
nvidia-smi -c 0

deviceQueryDrv and deviceQuery (both compiled successfully) hang on this line of output:

Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

CUDA-Z hangs as well.

Seems to work with 9.0 version of the CUDA Toolkit. However, as of this wriging, Gohlke’s libraries don’t contain pycuda built with 9.0. So had to build it from source.

Here are the arguments I used for .\configure:

c:\bin\python36\python.exe .\configure.py --boost-inc-dir=c:\bin\boost_1_65_1 --boost-lib-dir=c:\bin\boost_1_65_1\lib64-msvc-14.0 --cuda-root=C:\bin\CUDA\v9.0 --boost-compiler=msvc

Maybe this helps someone.