【报错】UserWarning: CUDA initialization: Unexpected error from cudaGetDeviceCount().

问题

服务器重启后,使用显卡的程序突然不能运行了,运行torch.cuda.is_available()报标题的错误。

具体如下:

>>> import torch
>>> torch.cuda
<module 'torch.cuda' from '/home/gpu-server/anaconda3/lib/python3.7/site-packages/torch/cuda/__init__.py'>
>>> torch.cuda.is_available
<function is_available at 0x7fb8f79017a0>
>>> torch.cuda.is_available()
/home/gpu-server/anaconda3/lib/python3.7/site-packages/torch/cuda/__init__.py:88: UserWarning: CUDA initialization: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 101: invalid device ordinal (Triggered internally at ../c10/cuda/CUDAFunctions.cpp:109.)
  return torch._C._cuda_getDeviceCount() > 0
False
>>> torch.cuda.device_count
<functools._lru_cache_wrapper object at 0x7fb8f783fd70>
>>> torch.cuda.device_count()
7

解决

sudo reboot

参考:https://stackoverflow.com/questions/66371130/cuda-initialization-unexpected-error-from-cudagetdevicecount

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值