在colab中,cuda不能用于火炬

问题描述 投票:-4回答:1

错误消息如下:

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
pytorch google-colaboratory torch
1个回答
2
投票

单击Runtime并在Hardware Acceleration中选择Change runtime type,选择GPU并点击Save

© www.soinside.com 2019 - 2024. All rights reserved.