Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Gaudi hpu accelerator option to BaseCAM #547

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

daniel-de-leon-user293
Copy link
Contributor

Hello!

This PR adds the option for users to use BaseCAM with Intel's Gaudi platform. The htcore import and mark_step() call are all that is needed in base_cam.py and I've added the 'hpu' arg in cam.py.

It should be noted that Gaudi needs a few (depending on model and input feature size) warmup executions before seeing the best computation time and is best for running GradCAM on large batches.

Steps to use cam.py on a Gaudi platform

Option 1. If you do not have access to a Gaudi locally

a. Use the free Tiber Cloud
b. In a terminal tab on the Jupyter lab interface, clone this branch

git clone -b daniel/enable_gaudi https://github.com/daniel-de-leon-user293/pytorch-grad-cam.git

c. Install dependencies

cd pytorch-grad-cam
pip install -e .

d. Run cam.py

python3 cam.py --device hpu

Option 2. If you do have access to a Gaudi locally

a. Clone this branch on your Gaudi machine

git clone -b daniel/enable_gaudi https://github.com/daniel-de-leon-user293/pytorch-grad-cam.git

b. Start a Gaudi container that mounts this branch

docker run -d --rm -it --name gradcam-hpu -v pytorch-grad-cam:/workdir --runtime=habana \ 
-e http_proxy=$http_proxy -e https_proxy=$https_proxy \ 
-e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none \ 
--cap-add=sys_nice --net=host --ipc=host \ 
vault.habana.ai/gaudi-docker/1.18.0/ubuntu22.04/habanalabs/pytorch-installer-2.2.2:latest

c. Exec into the interactive container

docker exec -it gradcam-hpu bash

d. Install dependencies

cd pytorch-grad-cam
pip install -e .

e. Run cam.py

python3 cam.py --device hpu

Thank you and look forward to hearing your feedback!

Signed-off-by: Daniel Deleon <daniel.de.leon@intel.com>
Signed-off-by: Daniel Deleon <daniel.de.leon@intel.com>
@jacobgil
Copy link
Owner

Thank you for the contribution !

@jacobgil jacobgil merged commit a2a23f8 into jacobgil:master Dec 17, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants