Disable the gpu.
57 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Good morning,
I have matlab version 2022b and I would like to disable the system GPU from the matlab application so that it does not recognise it and runs the programs only using the cpu. Could you tell me if it is possible to do it and how to do it? I would like to do it from the application itself, as disabling the gpu from the system is more laborious and I just want matlab to not recognise it.
Thank you.
0 Kommentare
Antworten (3)
Joss Knight
am 15 Jan. 2023
As soon as you start MATLAB type
setenv CUDA_VISIBLE_DEVICES -1
MATLAB will no longer recognise any GPU for computation.
2 Kommentare
Walter Roberson
am 15 Jan. 2023
Interesting!
I take it that variable is only tested the first time that gpu would be relevant, and that there is no way to force the test to be reset?
Joss Knight
am 15 Jan. 2023
This is a variable recognised by the CUDA driver and only checked when the driver is initialized, which happens the first time you use or query the GPU. So correct, there is no way to reset this without restarting MATLAB. Alternatively, use a process pool which can be stopped and restarted at will.
Luca Ferro
am 13 Jan. 2023
the command:
gpuDevice([]);
should do the trick.
Mind that it requires that the Parallel Computing Toolbox is installed.
For more informations you can check here
1 Kommentar
Walter Roberson
am 13 Jan. 2023
If you have code along the lines of
if gpu is detected
run deep learning on gpu
else
run deep learning on cpu
end
and you want to calculate the timings both ways without changing the detection test... then selecting the empty gpu is probably not going to be enough. But it would depend on how the gpu detection is coded.
Matt J
am 13 Jan. 2023
Bearbeitet: Matt J
am 13 Jan. 2023
Matlab will use the CPU by default unless you have in some way told it to use the GPU for a specific computation.
An exception might be the trainNetwork and predict commands, if you are doing DNN training or inference. Those commands have an option, however, called ExecutionEnvironment that you can use to specify CPU-only computation.
6 Kommentare
Matt J
am 24 Mär. 2023
dlnetwork's execution environment is determined by the attributes of its input data and parameters.
Joss Knight
am 24 Mär. 2023
That's a separate thing, although the kinds of accelerations we can do are affected by the environment.
Siehe auch
Kategorien
Mehr zu Parallel and Cloud finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!