简体   繁体   English

使用 detecto 在 GPU 而不是 CPU 上运行代码

[英]Run code on GPU instead of CPU with detecto

I am using machine learning with detecto in Python. However, whenever I run it, I get a warning saying我在 Python 中将机器学习与 detecto 结合使用。但是,每当我运行它时,我都会收到一条警告说

It looks like you're training your model on a CPU. Consider switching to a GPU; otherwise, 
this method can take hours upon hours or even days to finish. For more information, see 
https://detecto.readthedocs.io/en/latest/usage/quickstart.html#technical-requirements 

I have a GPU in the form of an Intel(R) HD graphics 4600 , but for some reason the code is running on the CPU.我有一个 GPU 形式的Intel(R) HD graphics 4600 ,但由于某种原因代码在 CPU 上运行。 I have checked out the link it gives which says我已经查看了它提供的链接

By default, Detecto will run all heavy-duty code on the GPU if it's available and on the CPU otherwise.默认情况下,如果 GPU 可用,则 Detecto 将在 CPU 上运行所有重型代码,否则将在 CPU 上运行。

It recommends using Google Collab if the computer doesn't have a GPU it can use, but I do have one, and don't want to use Google Collab.如果计算机没有可以使用的 GPU,它建议使用 Google Collab,但我有一个,并且不想使用 Google Collab。

Why is it running on the CPU instead of the GPU?为什么它运行在 CPU 而不是 GPU 上? And how can I fix it?我该如何解决? The part of my code where I get the warning is我收到警告的代码部分是

losses = fitmodel(loader, Test_dataset, epochs=25, lr_step_size=5, 
learning_rate=0.001, verbose=True)

The code does work, however it takes ages to run, so want to be able to run it on the GPU to save time.该代码确实有效,但是运行起来需要很长时间,因此希望能够在 GPU 上运行它以节省时间。

The GPU that detecto is referring to would need to be a CUDA capable Nvidia GPU. So your Intel(R) HD graphics 4600 does not meet this criterion. detecto所指的 GPU 需要是支持 CUDA 的 Nvidia GPU。因此您的Intel(R) HD 显卡 4600不符合此标准。

Detecto uses pytorch internally, whichs GPU support is based on CUDA . Detecto在内部使用 pytorch,其中 GPU 支持基于 CUDA So in order to use a GPU, you would need to move to a machine that has a CUDA capable card因此,为了使用 GPU,您需要移动到具有 CUDA 卡的机器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM