How many cores does MATLAB use in a given program?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
This might be an odd question, but my code has to be run on a more powerful machine. What would be helpful is to know how many cores my program uses. I don't know how to obtain this information. Would anyone be able to provide some suggestions?
採用された回答
John D'Errico
2017 年 11 月 7 日
On my computer...
maxNumCompThreads
ans =
4
How many cores your code actually uses on any given code is far more difficult. MATLAB can sometimes launch extra threads for large problems, but ONLY if it decides there will be a gain in so doing. So any given code may vary in the number of cores it will end up using. With some effort, I can force all of my cores to run flat out, but most simple computations never launch any additional cores.
I would suggest that you test run your code, watching a system monitor that will tell how many cores are active for MATLAB. How you do that will depend on what computer you are using. On my Mac, it is the activity monitor utility that I would use.
8 件のコメント
BM
2017 年 11 月 7 日
I use Linux, do you have any suggestions of the best program to accomplish this task in Linux? Thanks for your suggestion, by the way!
John D'Errico
2017 年 11 月 7 日
Sorry, but I am clueless about any other OS than a Mac. Ok, some will suggest I am just clueless in general. :)
Stephen23
2017 年 11 月 7 日
"... best program to accomplish this task ..."
The best program to accomplish what task ?
John D'Errico
2017 年 11 月 7 日
To show the number of cores currently active (in MATLAB) on a Linux system.
BM
2017 年 11 月 8 日
Exactly. I already knew of some monitoring programs on Linux, but the ones I know about are a little less clear, at least to me, then what I have seen on other operating systems.
John D'Errico
2017 年 11 月 8 日
The one on the Mac is pretty nice. Run the utility. A graphic window pops up. You tell it to watch the CPU utilization with a menu. Then go off and use MATLAB, with one eye on the monitor.
Or, I just listen for the fan to kick in. If it starts kicking in, then I know all CPUS are busy. :)
Shaily_T
2022 年 6 月 6 日
Hi, I have a related question and I appreciate your comment. I tried your nice suggestion, and when I run my code in Matlab, the activity monitor says 100% CPU is being used. And sometimes it shows even more than 100%. Does that mean all of the cores are used for running the code?
I have a Matlab code for fitting a custom model to a series of data. The actual number of data I have is about 600000. I can run the code for a selection of the data (6000 points), and it works fine. But I need to know the answer for the actual data size, and when I run the fit code, it takes a long time on my laptop to run, and it doesn't get to work. My laptop has four physical cores, and when I run Matlab code, the Activity Monitor on my MAC says 100% for CPU usage.
I am thinking of running my code on a cluster, but if the current laptop is not using all the available cores, I don't believe running it on a cluster would be helpful. The algorithm of my fit code is not something that I can write as a suitable format for parallel computing.
Do you have any thoughts?
Walter Roberson
2022 年 6 月 6 日
MacOS Activity monitor shows work relative to one core. A "single core" process can exceed 100% due to hyperthreading. If your Mac were running flat out on four physical cores it would approach 400%
MATLAB automatically uses parallel libraries for some of the operations, provided that the arrays are "large enough" (size is dependent on the operation). Not routinely seeing hundreds implies that your code either is not making much use of those mathematical operations, or else that your arrays are too small for it to help.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
