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

Ensure the alternative ND manager can use GPUs #3138

Merged

Conversation

david-sitsky
Copy link
Contributor

This makes a massive performance difference when using OnnxRuntime, which delegates to PyTorch for some NDArray operations. This almost makes OnnxRuntime run as fast compared to PyTorch. Without this change, OnnxRuntime was over 3 times slower.

alternativeManager = engine.newBaseManager(device);
} catch (RuntimeException | UnsatisfiedLinkError ignore) {
// Use the default device instead.
alternativeManager = engine.newBaseManager();
Copy link
Contributor

@frankfliu frankfliu Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's arguable using the same device is the best. For simplicity, I prefer use default device directly.

The UnsatisfiedLinkError error you hit is a caching issue (only affect development time), not related here. You can just need to clear your rust JNI cache:

rm -rf ~/.djl.ai/tokenizer
gradle :extensions:tokenizers:clean

David Sitsky and others added 2 commits April 29, 2024 16:10
This makes a massive performance difference when using OnnxRuntime,
which delegates to PyTorch for some NDArray operations.
@frankfliu frankfliu merged commit 399b310 into deepjavalibrary:master Apr 29, 2024
5 checks passed
@david-sitsky
Copy link
Contributor Author

@frankfliu - on my tests with my application (which does a lot of non-GPU work too), my original change ran in 6m 8s, but with the change not to keep the device, this went to 6m 25s. So it is a significant performance hit on multi-GPU systems, and for other workloads the discepancy will be much higher.

I also saw GPU 0 having way higher (too high) utilisation compared to the other GPUs since this is the default device set for the alternative ND manager, for all my worker processes (16 on my test).

Can't we keep my original change without the catch for UnsatisfiedLinkError? Otherwise this puts OnnxRuntime further away from PyTorch again, which won't have this issue.

@frankfliu
Copy link
Contributor

@david-sitsky

You are right, in multiple GPU case, it does make sense to keep original device. I just doesn't like try catch. Let me think a bit, there should a simple way.

@david-sitsky
Copy link
Contributor Author

@frankfliu - any ideas with this? I am pretty keen to get that multi-GPU performance back. 😉

@frankfliu
Copy link
Contributor

@david-sitsky

I created a PR: #3146

@david-sitsky
Copy link
Contributor Author

Awesome - thank you. That looks like a better way of achieving it too.

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.

None yet

3 participants