Coder Social home page Coder Social logo

Comments (8)

WilliWespe avatar WilliWespe commented on August 28, 2024 1

Yes, I did something similar to this. In my case I explicitly wanted the computations to be on the gpu. I edited the utils.py file in the pathml package like this:

In line 73 write: true_1_hot = torch.eye(num_classes + 1).to('cuda:0')[true.squeeze(1)]

You also have to add .to('cuda:0') to the tensor in line 84 (the else block).

Until now the program runs. I couldn't test a full training so far, because it needs to long. (17 hours for a full training. Is this normal?)

But the outer for loop ran for two iterations without error.

from pathml.

WilliWespe avatar WilliWespe commented on August 28, 2024

I have the exact same problem. I also run it on HPC but with 2 GPUs, each having 15G memory.
I think it has something to do with the newest torch version 1.13.0: pytorch/pytorch#90194

So far I couldn't resolve the problem.
Did you (or anybody else) find a solution?

from pathml.

jacob-rosenthal avatar jacob-rosenthal commented on August 28, 2024

Is this happening because torch.eye() is created on cpu but the true array has already been sent to the device? If so, maybe it would help to create the torch.eye on the same device, e.g. something like: true_1_hot = torch.eye(num_classes + 1, device = device)[true.squeeze(1)]. Or, you could try sending them all to cpu, something like true_1_hot = torch.eye(num_classes + 1)[true.cpu().squeeze(1)]

from pathml.

luzy05111036 avatar luzy05111036 commented on August 28, 2024

@WilliWespe how to edit the utils.py in pathml? I clone the pathml to hpc, then edit the utils.py, and use the second method to install pathml. But, there are several errors.

from pathml.

WilliWespe avatar WilliWespe commented on August 28, 2024

Well, in my case i first changed my directory to miniconda3/envs/py38/lib/python3.8/site-packages/pathml/ml.
Then I opened utils.py with nano and edited/saved it. After that restart your notebook.

Was this your question?

from pathml.

luzy05111036 avatar luzy05111036 commented on August 28, 2024

@WilliWespe thanks. Yes, that's my question and it works. I am starting training now.

from pathml.

luzy05111036 avatar luzy05111036 commented on August 28, 2024

problem solved

from pathml.

FerranC96 avatar FerranC96 commented on August 28, 2024

Thank you all for the discussion above!
Can confirm the patch above still works in 2024 with pathml 2.1.1

from pathml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.