Skip to content

Conversation

daniel-de-leon-user293
Copy link
Owner

@daniel-de-leon-user293 daniel-de-leon-user293 commented Dec 16, 2024

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 <[email protected]>
@daniel-de-leon-user293 daniel-de-leon-user293 marked this pull request as draft December 16, 2024 20:37
Signed-off-by: Daniel Deleon <[email protected]>
@daniel-de-leon-user293 daniel-de-leon-user293 marked this pull request as ready for review December 16, 2024 22:50
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.

1 participant