Documentation: Multiple GPUs
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Dokumentation
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- python
- Bereich
- documentation
Rechercherichtung
Beginnen Sie damit, das bereitgestellte Python-Beispiel und die vorhandenen Dokumentationsbeispiele des Repositorys zu prüfen, um zu bestimmen, wo ein Beispiel für mehrere GPUs hingehört. Überprüfen Sie, dass das Beispiel korrekt und reproduzierbar ist, und fügen Sie es anschließend an der passenden Stelle in der Dokumentation hinzu; als erledigt gilt die Aufgabe, wenn das Beispiel die Einrichtung für mehrere GPUs erklärt und wie beschrieben funktioniert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
I think it would be great to have an example for using multiple GPUs.
Here is what I tried. If thats the right way to do it, then you may add it as an example.
It seems to scale fine (tested up to 7 GPUs) and nvidia-smi reports 96% util.
import time
import numpy as np
import arrayfire as af
import argparse
af.set_backend('cuda')
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('gpus', type=int)
parser.add_argument('-runs', type=int, default=100)
args = parser.parse_args()
GPUS = args.gpus
N = 5000
runs = args.runs
# The simple task we want to solve:
# we have a huge list of vectors X and want to calculate the distance between all of them
# this will result in a huge distance matrix M
# the resulting matrix should be multiplied by a vector alpha
X = np.random.rand(100, N)
Alpha = np.random.rand(N,1)
#copy data once:
xGPU = []
alphaGPU = []
for i in range(GPUS):
af.set_device(i)
x = af.to_array(X)
xGPU.append(x)
alpha = af.to_array(Alpha)
alphaGPU.append(alpha)
sub = lambda a,b: a - b
print("init finished")
for _ in range(runs):
startTime = time.time()
splitSize = int(np.ceil(N / GPUS))
#print("Temp data will ocupy at least {:.2f} MB on the gpu.".format((X.shape[0] * splitSize * X.shape[1]) *8 /1024/1024))
result = []
for i in range(GPUS):
af.set_device(i)
x = xGPU[i]
alpha = alphaGPU[i]
start = i*splitSize
end = min((i+1)*splitSize, N)
diff = af.broadcast(sub, af.tile(x[:,start:end],1,1,x.shape[1]), af.moddims(x,x.shape[0],1,x.shape[1]))
diff = af.sqrt(af.sum(af.pow(diff,2),0) )
r = af.matmul(af.moddims(diff, diff.shape[1], diff.shape[2]), alpha)
result.append(r)
total = 0
for i in range(GPUS):
af.set_device(i)
total += af.sum(result[i])
print("Took {} sec".format(time.time() - startTime ))
- Vorherrschende Sprache
- Python
- Sterne
- 422
- Forks
- 63
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus arrayfire/arrayfire-python
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
arrayfire/arrayfire-python#271 ·
-
Unwrap phase function Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
arrayfire/arrayfire-python#270 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
arrayfire/arrayfire-python#269 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 38/100
arrayfire/arrayfire-python#268 · 1 Kommentar ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
arrayfire/arrayfire-python#267 · 1 Kommentar · 1 Reaktion ·
Alle Issues in arrayfire/arrayfire-python
Ähnliche Issues
-
Add: hunch Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
DiamondLightSource/dodal#2211 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
openml/openml-python#1749 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
sipyourdrink-ltd/bernstein#6191 ·