Step 1: Ensure that the version of the graphics card driver corresponds to the CUDA version.
Turn: How to check the CUDA version supported by Nvidia in Win10
Then download the corresponding cuda version on the official website. During the download process, cudnn corresponds to cuda.
Step 2: If the cudaGetDeviceCount returned 30 -> unknown error problem occurs, you need to uninstall the graphics driver (installed by cuda), and uninstall it in the control panel-uninstall program (restart eventually)