Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU support #54

Open
kichik opened this issue Jun 21, 2022 · 2 comments
Open

GPU support #54

kichik opened this issue Jun 21, 2022 · 2 comments

Comments

@kichik
Copy link
Member

kichik commented Jun 21, 2022

No description provided.

@wesk
Copy link

wesk commented Apr 21, 2023

Does GPU support exist today for any of the providers (e.g. EC2, ECS)?

@kichik
Copy link
Member Author

kichik commented Apr 21, 2023

This one worked for me:

const version = '530';
const gpuImageBuilder = Ec2RunnerProvider.imageBuilder(this, 'GPU Image Builder');
gpuImageBuilder.addComponent(RunnerImageComponent.custom({
  name: 'nvidia-drivers',
  commands: [
    'export DEBIAN_FRONTEND=noninteractive',
    `apt-get install -y linux-modules-nvidia-${version}-aws nvidia-headless-${version}`,
    `apt-get install -y nvidia-utils-${version}-server || apt-get install -y nvidia-utils-${version}`,
  ],
}));

new GitHubRunners(this, 'runners', {
  providers: [
    new Ec2RunnerProvider(this, 'EC2 Linux GPU', {
      labels: ['ec2', 'linux', 'gpu'],
      instanceType: ec2.InstanceType.of(ec2.InstanceClass.G4DN, ec2.InstanceSize.XLARGE),
      imageBuilder: gpuImageBuilder,
    }),
  ],
});

For Amazon Linux 2:

const version = '530';
const gpuImageBuilder = Ec2RunnerProvider.imageBuilder(this, 'GPU Image Builder');
gpuImageBuilder.addComponent(RunnerImageComponent.custom({
  name: 'nvidia-drivers',
  commands: [
    'curl -o /etc/yum.repos.d/cuda-rhel7.repo http://developer.download.nvidia.com/compute/cuda/repos/rhel7/$( /bin/arch )/cuda-rhel7.repo',
    `yum install -y nvidia-driver-branch-${version}`,
    `amazon-linux-extras install -y kernel-ngct${version}`,
  ],
}));

Or you can use a pre-configured AMI:

const gpuImageBuilder = Ec2RunnerProvider.imageBuilder(this, 'GPU Image Builder', {
  baseAmi: ecs.EcsOptimizedImage.amazonLinux2(ecs.AmiHardwareType.GPU).getImage(this).imageId,
  os: Os.LINUX_AMAZON_2,
});

new GitHubRunners(this, 'runners', {
  providers: [
    new Ec2RunnerProvider(this, 'EC2 Linux GPU', {
      labels: ['ec2', 'linux', 'gpu'],
      instanceType: ec2.InstanceType.of(ec2.InstanceClass.G4DN, ec2.InstanceSize.XLARGE),
      imageBuilder: gpuImageBuilder,
    }),
  ],
});

Other providers require code changes or using CDK escape hatches as they will need (currently) unexposed settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants