Comments (5)
Adding triage review
to discuss what do do about various performance issue and how we should approach them
from pytorch.
By using .sched_setaffinity()
you are basically telling your OS to only allow the current process to use certain CPU cores. torch
will use torch.get_num_threads()
(usually CPU cores/2) threads for computation by default. So in your example you will force the OS to schedule N threads on N-1 cores which probably leads to some very heavy congestion.
You should probably use torch.set_num_threads()
to limit the number of threads torch
will use.
from pytorch.
It feels like this issue belong to https://discuss.pytorch.org/
Though if I'm to rephrase it, it probably about documenting what are the interoperability expectations between PyTorch runtime (which uses OpenMP) and Python threading library
Also, I wonder if torch.set_num_threads(len(core_ids))
will help
from pytorch.
@tringwald @malfet
Thank you for your response. I used torch.set_num_threads() and it solved the problem, but I found that when I use more than 8 cores, the thread execution time increases. It seems that using 8 cores gives the best performance. I've created a chart where the X-axis represents the number of cores used and the Y-axis shows the execution time for the threads.
The results I obtained on another server with a 72-core CPU are as follows (this server is shared with other users, which might affect performance).
from pytorch.
Your CPU only has 8 (or 36) physical cores, with hyperthreading/SMT that makes 16/72 logical cores. SMT only really helps when waiting for something like IO. In a heavy number crunching task like NN inference, there is no real advantage of using logical cores. Having multiple threads fight for the same physical core only leads to congestion and cache eviction.
from pytorch.
Related Issues (20)
- RuntimeError: "fill_empty_deterministic_" not implemented for 'ComplexHalf' HOT 1
- RuntimeError: "fill_empty_deterministic_" not implemented for 'ComplexHalf' HOT 3
- `torch.load` with `weights_only=True` does not allow `bytes` or `bytearray`
- [torch.compile] Integers stored on nn.Modules as dynamic causing errors HOT 3
- Request for Mirroring PyTorch Official WHL Repository HOT 7
- The more detailed GELU formula should be added to the doc of `GELU()`: HOT 2
- NameError('math is not defined') - malformed Triton codegen with math.trunc HOT 2
- Export on to_dense() fails on compressed cases, works for COO HOT 1
- [torch.fx] _FunctionalizationMetadataProp.propagate method can't use non-tensor args HOT 1
- Leaky ReLU of empty tensor doesn't work on MPS HOT 1
- MPS regression: RuntimeError: result.storage().use_count() == 1 INTERNAL ASSERT FAILED
- convolution_overrideable not implemented when executing VAEEncode in ComfyUI
- Graph break due to unsupported builtin sys.audit HOT 1
- DISABLED test_autograd_cpp_node_saved_float (__main__.TestCompiledAutograd) HOT 1
- Add nondeterministic alert to `.scatter_` HOT 1
- How to use libtorch in a c++11 project? HOT 1
- Batched flex attention to reduce max memory usage HOT 1
- IPC feature supports third-party devices HOT 1
- error occur when I use torch.onnx.export to generate onnx model HOT 5
- Tensor parallel for convolutions and groupnorm HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytorch.