Pytorch 在实验室中,CUDA不能用于火炬

Pytorch 在实验室中,CUDA不能用于火炬,pytorch,google-colaboratory,torch,Pytorch,Google Colaboratory,Torch,错误消息如下所示: RuntimeError Traceback (most recent call last) <ipython-input-24-06e96beb03a5> in <module>() 11 12 x_test = np.array(test_features) ---> 13 x_test_cuda = torch.tensor(x_test, dtype=torch.float).cuda() 14 test

错误消息如下所示:

RuntimeError   Traceback (most recent call last)
<ipython-input-24-06e96beb03a5> in <module>()
     11
     12 x_test = np.array(test_features)
---> 13 x_test_cuda = torch.tensor(x_test, dtype=torch.float).cuda()
     14 test = torch.utils.data.TensorDataset(x_test_cuda)
     15 test_loader = torch.utils.data.DataLoader(test, batch_size=batch_size, shuffle=False)

/usr/local/lib/python3.6/dist-packages/torch/cuda/__init__.py in _lazy_init()
    160 class CudaError(RuntimeError):
    161     def __init__(self, code):
--> 162         msg = cudart().cudaGetErrorString(code).decode('utf-8')
    163         super(CudaError, self).__init__('{0} ({1})'.format(msg, code))
    164

RuntimeError: cuda runtime error (38) : no CUDA-capable device is detected at /pytorch/aten/src/THC/THCGeneral.cpp:51
运行时错误回溯(最近一次调用)
在()
11
12 x_测试=np.阵列(测试特征)
--->13 x_测试_cuda=torch.tensor(x_测试,dtype=torch.float).cuda()
14测试=torch.utils.data.TensorDataset(x_测试_cuda)
15 test\u loader=torch.utils.data.DataLoader(test,batch\u size=batch\u size,shuffle=False)
/usr/local/lib/python3.6/dist-packages/torch/cuda/__-init__;u.py in_-lazy_-init()
160类CudaError(运行时错误):
161定义初始化(自身,代码):
-->162 msg=cudart().cudaGetErrorString(代码)。解码('utf-8')
163 super(CudaError,self)。uuu init_uuuu({0}({1})。格式(msg,代码))
164
运行时错误:cuda运行时错误(38):在/pytorch/aten/src/THC/THCGeneral.cpp:51处未检测到支持cuda的设备
单击运行时并选择更改运行时类型


现在在硬件加速中,选择GPU并点击Save。

您能说明您迄今为止尝试了什么吗?确切的设置是什么,你的相关代码是什么?你是否检查过你是否启用了GPU加速?是的,我没有打开这个GPU!非常感谢。你说的“火炬”是指什么?“Torch”的标签wiki上写着“Torch是LuaJIT的科学计算框架。它被世界各地的机器学习研究人员广泛使用。”。实际拼写是“Change runtime type”吗?@PeterMortensen是的