我们将我们的代码上传到服务器运行是,遇到下面问题:
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=50 error=100 :
no CUDA-capable device is detected Traceback (most recent call last): File
"HyperAttentionDTI_main.py", line 185, in <module> model =
AttentionDTI(hp).cuda() File
"/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 304,
in cuda return self._apply(lambda t: t.cuda(device)) File
"/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 201,
in _apply module._apply(fn) File
"/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 223,
in _apply param_applied = fn(param) File
"/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 304,
in <lambda> return self._apply(lambda t: t.cuda(device)) File
"/usr/local/lib/python3.7/site-packages/torch/cuda/__init__.py", line 197, in
_lazy_init torch._C._cuda_init() RuntimeError: cuda runtime error (100) : no
CUDA-capable device is detected at /pytorch/aten/src/THC/THCGeneral.cpp:50
是因为我们的显卡设置错误,因为我们有没有显卡,自己知道,不然不会报错显卡问题
解决办法:
我们看看自己执行的程序代码,好好检查cuda部分,我把我的显卡设置成了6,名我们没那么多显卡可以用,我查看了自己的显卡位置,在0号,所以,我们把下面的代码第一行,设置为0,就可以了!
os.environ["CUDA_VISIBLE_DEVICES"] = "6" if __name__ == "__main__": """select
seed""" SEED = 1234 random.seed(SEED) torch.manual_seed(SEED)
torch.cuda.manual_seed_all(SEED) # torch.backends.cudnn.deterministic = True