mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
fix(gpu) EE-3191 fix gpu bugs (#7451)
This commit is contained in:
parent
36888b5ad4
commit
04eb718f88
2 changed files with 54 additions and 24 deletions
|
@ -72,7 +72,7 @@ angular.module('portainer.docker').controller('CreateContainerController', [
|
|||
GPU: {
|
||||
enabled: false,
|
||||
useSpecific: false,
|
||||
selectedGPUs: [],
|
||||
selectedGPUs: ['all'],
|
||||
capabilities: ['compute', 'utility'],
|
||||
},
|
||||
Console: 'none',
|
||||
|
@ -469,28 +469,24 @@ angular.module('portainer.docker').controller('CreateContainerController', [
|
|||
function prepareGPUOptions(config) {
|
||||
const driver = 'nvidia';
|
||||
const gpuOptions = $scope.formValues.GPU;
|
||||
|
||||
const existingDeviceRequest = _.find($scope.config.HostConfig.DeviceRequests, function (o) {
|
||||
return o.Driver === driver || o.Capabilities[0][0] === 'gpu';
|
||||
});
|
||||
const existingDeviceRequest = _.find($scope.config.HostConfig.DeviceRequests, { Driver: driver });
|
||||
if (existingDeviceRequest) {
|
||||
_.pullAllBy(config.HostConfig.DeviceRequests, [existingDeviceRequest], 'Driver');
|
||||
}
|
||||
|
||||
if (!gpuOptions.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const deviceRequest = existingDeviceRequest || {
|
||||
const deviceRequest = {
|
||||
Driver: driver,
|
||||
Count: -1,
|
||||
DeviceIDs: [], // must be empty if Count != 0 https://github.com/moby/moby/blob/master/daemon/nvidia_linux.go#L50
|
||||
Capabilities: [], // array of ORed arrays of ANDed capabilites = [ [c1 AND c2] OR [c1 AND c3] ] : https://github.com/moby/moby/blob/master/api/types/container/host_config.go#L272
|
||||
// Options: { property1: "string", property2: "string" }, // seems to never be evaluated/used in docker API ?
|
||||
};
|
||||
|
||||
deviceRequest.DeviceIDs = gpuOptions.selectedGPUs;
|
||||
deviceRequest.Count = 0;
|
||||
if (gpuOptions.useSpecific) {
|
||||
deviceRequest.DeviceIDs = gpuOptions.selectedGPUs;
|
||||
deviceRequest.Count = 0;
|
||||
}
|
||||
deviceRequest.Capabilities = [gpuOptions.capabilities];
|
||||
|
||||
config.HostConfig.DeviceRequests.push(deviceRequest);
|
||||
|
@ -661,6 +657,8 @@ angular.module('portainer.docker').controller('CreateContainerController', [
|
|||
$scope.formValues.GPU.selectedGPUs = deviceRequest.DeviceIDs || [];
|
||||
if ($scope.formValues.GPU.useSpecific) {
|
||||
$scope.formValues.GPU.selectedGPUs = deviceRequest.DeviceIDs;
|
||||
} else {
|
||||
$scope.formValues.GPU.selectedGPUs = ['all'];
|
||||
}
|
||||
// we only support a single set of capabilities for now
|
||||
// UI needs to be reworked in order to support OR combinations of AND capabilities
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue