# Distributed Worker Pool Example - Support for Specific Hardware

**URL:** <https://forums.swift.org/t/distributed-worker-pool-example-support-for-specific-hardware/53973>\
**Category:** Distributed Actors\
**Created:** [December 10, 2021, 6:29pm UTC](https://forums.swift.org/t/distributed-worker-pool-example-support-for-specific-hardware/53973 "2021-12-10T18:29:47Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![ktoso](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ktoso/32/44526_2.png) [@ktoso](https://forums.swift.org/u/ktoso)\
**Post date:** [December 12, 2021, 5:36am UTC](https://forums.swift.org/t/distributed-worker-pool-example-support-for-specific-hardware/53973/4 "2021-12-12T05:36:15Z")

</div>

I'm not quite sure what you're asking for with:

> [@spprichard](#):
>
> Specifically, how would the actor know how to use the GPU?

I mean, you write the code in the actor, so it's up to you to write whatever "this code needs gpu stuff" in an actor that will be run on a node that "has the gpu" (whatever that specifically means, e.g. a high-gpu instance on EC2 or something else etc).

> [@spprichard](#):
>
> Which when doing this we could create an Actor type that has an initializer that perhaps takes in some GPU specific transportation information which tells the actor how to communicate with the GPU when dispatching work.

This is perhaps either weirdly phrased, or misunderstands what actors are doing (or I don't understand the sentence)? Actors are not going to "use the gpu" just in some magical way. Distributed actors are just a communication mechanism, whatever code you have that _already does_ require/make-use-of gpu acceleration would just be sitting there as usual ("in the actor"), and the actor only serves as nice way to discover and communicate with any such actor(s).

In practice the actor code is just:

```swift
if <I'm a high-gpu instance> { 
  ... = HighGPUWorker(system: cluster, ...)
} else {
  // normal node... don't spawn high gpu workers
}

distributed actor HighGPUWorker { 
  init(system: ActorSystem, ...) {
    system.receptionist.register(self, withKey: .highGPUWorkers)
  }
}

// others are listening for .highGPUWorkers

```

You may want to watch the talk about this we did recently: [[Video] Distributed Actors announced at Scale by the Bay](https://forums.swift.org/t/video-distributed-actors-announced-at-scale-by-the-bay/53909) maybe that'll help with wrapping your head around the usage patterns 🙂

---

_[View the full topic](https://forums.swift.org/t/distributed-worker-pool-example-support-for-specific-hardware/53973)._
