simple-HRNet icon indicating copy to clipboard operation
simple-HRNet copied to clipboard

Running it on GPU on google collab ?

Open basicvisual opened this issue 4 years ago • 11 comments

Hi , I managed to run your code on google collab. It worked fine but it always choose the "CPU" as default value . I was wondering if there is a setting in the code that has to be changed in order to use the GPU ?

basicvisual avatar May 07 '21 22:05 basicvisual

Hi @basicvisual , awesome! Are you willing to share the notebook so that I can add it to this repository (with proper referencing)?

Regarding running it on GPU, have you changed the Colab "Runtime type" from CPU to GPU or TPU? Does it still run on CPU even choosing one of these options? You can check if you have access to a GPU/TPU using torch.cuda.is_available().

In general, you can set the device you want to use when initializing SimpleHRNet (as done here). For using a GPU, set it to device=torch.device('cuda').

stefanopini avatar May 08 '21 22:05 stefanopini

Hi @stefanopini , its a very very experimental notebook. Let me have a look if i can make it better , as of now its just downloading the repo , adding the weights ( lot of manual steps) , Can i come back to you in some time with a better version or I can already send a link to the barebone version of the notebook. For some reason yes it still runs in CPU even if the runtime is changed to GPU . So i was a bit confused .

basicvisual avatar May 10 '21 07:05 basicvisual

Sure! If you are willing to share the notebook, feel free to share it at your convenience/when you think it is ready! 🙂

Regarding the issue, that's weird. It should run on the GPU if available. Does torch.cuda.is_available() return True? Is it running on CPU even setting device=torch.device('cuda')? If you'd like, I can have a look at the current notebook to try to understand what is causing the issue. In this case, just make a copy and share it with me.

stefanopini avatar May 11 '21 23:05 stefanopini

Hi this is the link for the colab notebook , as mentioned its very early stage : here

basicvisual avatar May 12 '21 21:05 basicvisual

Wonderful, thank you!

I've been able to have it working and it did run on GPU. I just had to switch twice from CPU to GPU runtime, but after that import torch; print(torch.cuda.is_available()) gave me True and the script run on GPU afterwards. Let me know if this works for you too.

In the next days/weeks, I'll continue working on it with the goal of adding it to this repository, thank you very much!

stefanopini avatar May 13 '21 21:05 stefanopini

Thank you . I think one of the steps which is manual , is pointing to the pre trained weights. I am wondering if one can mount the pre trained google drive then one can exclude manual download and upload to the weights.

Another question or possibility is to see if multiple videos can be executed in one go ? like have a list of videos to process ? I think that would require changes in the live-demo.py code ?

basicvisual avatar May 17 '21 09:05 basicvisual

I think it is possible to mount a Google Drive folder, but it requires an API key, so it wouldn't be automatic also in this case. However, I think that the current code is quite handy: you just need to replace a code to download/use a specific file.

I'm afraid it would. But one could make a for loop on a list of file and call the live-demo.py script for every file, or embed the code of the live-script.py script into the notebook instead of calling the script.

stefanopini avatar May 23 '21 22:05 stefanopini

m afraid it would. But one could make a for loop on a list of file and call the live-demo.py script for every file, or embed the code of the live-script.py script into the notebook instead of calling the script.

I think that would be some what straight forward. I was wondering , we need to change the output.avi ( part of the code as well) Otherwise it will overwrite the video ( i think so )

basicvisual avatar May 28 '21 08:05 basicvisual

Yes, definitely

stefanopini avatar Jun 07 '21 22:06 stefanopini

I think it is possible to mount a Google Drive folder, but it requires an API key, so it wouldn't be automatic also in this case. However, I think that the current code is quite handy: you just need to replace a code to download/use a specific file.

Hello, I have tried to rearrange the code provided by @basicvisual in a separate notebook here. As for the pre-trained weights, yes you need to mount your drive by manually inputting an API key after either

  1. manually downloading or uploading the file, or
  2. making a copy from the official drive to your own drive.

Details are given in the notebook. As for now, the code loads a COCO2017 image and detects keypoints. I think it serves as a good starting point for those interested in this repository.

wuyenlin avatar Aug 30 '21 09:08 wuyenlin

Wow, thank you! It is definitely a great starting point for people interested in this repo. I'll share it on the README.md with proper attribution.

stefanopini avatar Sep 20 '21 07:09 stefanopini

New, updated notebook supporting colab, testing also TensorRT and YOLOv5 added to the master branch! (See #100 )

stefanopini avatar Dec 29 '22 18:12 stefanopini