How to restrict train() function to a select gpu pool?

2 ビュー (過去 30 日間)
Ivan Rodionov
Ivan Rodionov 2025 年 2 月 8 日
コメント済み: Matt J 2025 年 2 月 27 日
Hello, I would like to restrict the train() function to run on gpuDevice(2) and gpuDevice(3) respectively while excluding gpuDevice(1) in my system. How would I change this code provided on the reference website to do this?
Note in the example above the function configure was used to set the dimensions and processing settings of the network's inputs. This normally happens automatically when train is called, but when providing gpuArray data this step must be done manually with non-gpuArray data.
Using only workers with unique GPUs might result in higher speed, as CPU workers might not keep up.
net = train(net,X,T,'useParallel','yes','useGPU','only');
Y = net(X);
When running, it executes on all gpus available.

回答 (1 件)

Matt J
Matt J 2025 年 2 月 9 日
This might work,
setenv('CUDA_VISIBLE_DEVICES', '1,2'); % MATLAB indexes from 1, CUDA from 0
  2 件のコメント
Ivan Rodionov
Ivan Rodionov 2025 年 2 月 26 日
Hello @Matt J and thank you for your reply, unfortunately this does not seem to work.
gpuDeviceTable
ans =
3×5 table
Index Name ComputeCapability DeviceAvailable DeviceSelected
_____ __________________ _________________ _______________ ______________
1 "GeForce GTX 1650" "7.5" true true
2 "Tesla K40c" "3.5" true false
3 "Tesla K40c" "3.5" true false
setenv('CUDA_VISIBLE_DEVICES', '1,2'); % MATLAB indexes from 1, CUDA from 0
gpuDeviceTable
ans =
3×5 table
Index Name ComputeCapability DeviceAvailable DeviceSelected
_____ __________________ _________________ _______________ ______________
1 "GeForce GTX 1650" "7.5" true true
2 "Tesla K40c" "3.5" true false
3 "Tesla K40c" "3.5" true false
Matt J
Matt J 2025 年 2 月 27 日
I think you have to restart Matlab for it to take effect, which I guess is not what you wanted...

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeParallel and Cloud についてさらに検索

タグ

製品


リリース

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by