How many cores does MATLAB use in a given program?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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!
Sorry, but I am clueless about any other OS than a Mac. Ok, some will suggest I am just clueless in general. :)
"... best program to accomplish this task ..."
The best program to accomplish what task ?
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.
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. :)
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?
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
