UserWarning: CUDA initialization: Unexpected error from cudaGetDeviceCount()【已解决】

报错

 PS C:\Users\example> python
Python 3.8.0 (default, Nov  6 2019, 16:00:02) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
D:\software\Anaconda3\envs\work38\lib\site-packages\torch\cuda\__init__.py:83: UserWarning: CUDA initialization: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 103: integrity checks failed (Triggered internally at  C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\c10\cuda\CUDAFunctions.cpp:109.)
  return torch._C._cuda_getDeviceCount() > 0
>>> torch.cuda.is_available()
False

查看原因

  • nvcc -V正常
 PS C:\Users\example> nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Fri_Dec_17_18:28:54_Pacific_Standard_Time_2021
Cuda compilation tools, release 11.6, V11.6.55
Build cuda_11.6.r11.6/compiler.30794723_0
  • nvidia-smi正常

解决方案

打开NVIDIA设置,升级显卡驱动后解决。

你可能感兴趣的:(Python,pytorch,深度学习,python)