如何在 Google colab 中激活 GPU 计算?
How to activate GPU computing in Google colab?
我是火炬手,python,
我正在尝试使用 Google COlab 在网上找到的一些机器学习代码,但出现以下错误:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-4-d4b0db6cedae> in <module>()
295 input_dropout=input_dropout, hidden_dropout1=hidden_dropout1,
296 hidden_dropout2= hidden_dropout2, label_smoothing= label_smoothing)
--> 297 experiment.train_and_eval()
298
299
2 frames
/usr/local/lib/python3.6/dist-packages/torch/cuda/__init__.py in _lazy_init()
195 "Cannot re-initialize CUDA in forked subprocess. " + msg)
196 _check_driver()
--> 197 torch._C._cuda_init()
198 _cudart = _load_cudart()
199 _cudart.cudaGetErrorName.restype = ctypes.c_char_p
RuntimeError: cuda runtime error (100) : no CUDA-capable device is detected at /pytorch/aten/src/THC/THCGeneral.cpp:50
我知道 cude 是用于 GPU 处理的?那么我该如何解决这个问题呢?
我正在试验 link:
中的代码
您尝试过以下方法吗?
Go to Menu > Runtime > Change runtime.
Change hardware acceleration to GPU.
How to install CUDA in Google Colab GPU's
除了上述答案,您也可以使用 Google 的 TPU。如果您是 Colab Pro,请注意:除非您确实需要,否则请避免使用它们,因为 Google 会降低您下次使用该资源的优先级:
来自their official description page
Resources in Colab Pro are prioritized for subscribers who have recently used less resources, in order to prevent the monopolization of limited resources by a small number of users. To get the most out of Colab Pro, consider closing your Colab tabs when you are done with your work, and avoid opting for GPUs or extra memory when it is not needed for your work. This will make it less likely that you will run into usage limits within Colab Pro.
我不确定对于普通用户来说是否如此。但根据我自己的经验,GPU 和 TPU 并不总是可用的。如果它们在您的编码过程中变得不可用,并且 运行,所有之前的 run/finished 单元格再次变为 "unrun"。所以你会冒一个小风险。
我是火炬手,python,
我正在尝试使用 Google COlab 在网上找到的一些机器学习代码,但出现以下错误:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-4-d4b0db6cedae> in <module>()
295 input_dropout=input_dropout, hidden_dropout1=hidden_dropout1,
296 hidden_dropout2= hidden_dropout2, label_smoothing= label_smoothing)
--> 297 experiment.train_and_eval()
298
299
2 frames
/usr/local/lib/python3.6/dist-packages/torch/cuda/__init__.py in _lazy_init()
195 "Cannot re-initialize CUDA in forked subprocess. " + msg)
196 _check_driver()
--> 197 torch._C._cuda_init()
198 _cudart = _load_cudart()
199 _cudart.cudaGetErrorName.restype = ctypes.c_char_p
RuntimeError: cuda runtime error (100) : no CUDA-capable device is detected at /pytorch/aten/src/THC/THCGeneral.cpp:50
我知道 cude 是用于 GPU 处理的?那么我该如何解决这个问题呢? 我正在试验 link:
中的代码您尝试过以下方法吗?
Go to Menu > Runtime > Change runtime.
Change hardware acceleration to GPU.
How to install CUDA in Google Colab GPU's
除了上述答案,您也可以使用 Google 的 TPU。如果您是 Colab Pro,请注意:除非您确实需要,否则请避免使用它们,因为 Google 会降低您下次使用该资源的优先级:
来自their official description page
Resources in Colab Pro are prioritized for subscribers who have recently used less resources, in order to prevent the monopolization of limited resources by a small number of users. To get the most out of Colab Pro, consider closing your Colab tabs when you are done with your work, and avoid opting for GPUs or extra memory when it is not needed for your work. This will make it less likely that you will run into usage limits within Colab Pro.
我不确定对于普通用户来说是否如此。但根据我自己的经验,GPU 和 TPU 并不总是可用的。如果它们在您的编码过程中变得不可用,并且 运行,所有之前的 run/finished 单元格再次变为 "unrun"。所以你会冒一个小风险。